Jump to content

Renaming directory and file within directory


OAFC_Rob
Go to solution Solved by 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); 
Link to comment
Share on other sites

  • Solution

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!! 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.