SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast SteveMif's Avatar
    Join Date
    Aug 2013
    Location
    Malta
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Cannot rename files in directories in Windows 7

    Hi, I have this very strange problem which is pulling out my hair.

    I want to rename a file in 3 or 4 level folder

    The code is simple:

    Code PHP:
    <?php
     
     
    				$oldthumb1path = "../TEST/Pics/TSTXX/TSTXX-Portulaca_nigra_t.jpg";
    				$newthumb1path = "../TEST/Pics/TSTXZ/TSTXZ-Portulaca_nigrescens_t.jpg";
     
     
    				print "<br><br>	Renaming $oldthumb1path to $newthumb1path ...";
    				if (rename ($oldthumb1path , $newthumb1path)) {print "<font color=green> Success! </font>";} else { print "<font color=red> Rename failed.</font>";}	
     
     
     
    ?>


    The result is that the renaming fails with a wrong error message:

    Warning: rename(..\TEST\Pics\TSTXX\TSTXX-Portulaca_nigra_t.jpg,..\TEST\Pics\TSTXZ\TSTXZ-Portulaca_nigrescens_t.jpg): No such file or directory in E:\WEBSITE....


    The php file is in a php folder common with folder TEst (hence the ../) The strange thing of them all is that if I place the php script in the folder were the file is present (hence in folder TSTXX) the renaming takes place successfully. I really need a tip to solve this since I been programming a long script to rename my web image files (10,000s) automatically, and I am not in the mood to rename them manually.


    What's wrong ? 100% sure that there is no typo in the filenames, and the destination file does not exist.

  2. #2
    SitePoint Enthusiast SteveMif's Avatar
    Join Date
    Aug 2013
    Location
    Malta
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I found the problem, it was my mistake with the folder TSTXZ was not created!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •