Jump to content

Renaming directory and file within directory


OAFC_Rob

Recommended Posts

I have a folder in the following public structure;

 

/public/assets/songs/test/mp3/test.mp3 

 

and I simply want to rename it to; 

 

/public/assets/songs/test1/mp3/test1/mp3 

 

So simply just change the main directory and the mp3 filename, simple enough or so I thought. I've tried loads of different combination and still can't seem to get both to rename. 

 

Here is the simplest form of my code; 

rename('./assets/songs/test', './assets/songs/test1');
rename('./assets/songs/test1/mp3/test.mp3', './assets/songs/test1/mp3/test1.mp3');

Any ideas? 

 

I have even tried to rename the directory with mv via exec but still nothing, this is really frustrating.

$cmd = 'mv ./assets/songs/test ./assets/songs/test1';
exec($cmd, $output, $return_val); 

Scrap that, it does work. It's the Mac file finder that's not updating the directory was changing but the file didn't seem to be but going via command line proved that the two lines of code were in fact working. 

 

Jesus,  just lost enough time to this issue because of switching over to a mac grrr!! 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.