Jump to content

[SOLVED] Rename function Error


Suchy

Recommended Posts

I have a simple script to rename files.

 

<?php
$path = 'fotki_upload';
$dir_handle = opendir($path);

while ($file = readdir($dir_handle)) 
   rename($file, strtoupper($file));

closedir($dir_handle);
?> 

 

But I am getting these errors.

Warning: rename(wixa.jpg,WIXA.JPG) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(.,.) [function.rename]: Device or resource busy in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(1.jpg,1.JPG) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(3.jpg,3.JPG) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(index.html,INDEX.HTML) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(..,..) [function.rename]: Device or resource busy in /home/suchygn/public_html/media/fotka/rename.php on line 9

 

What seems to be the problem, the direcotry where the files are i chomed to 777.

Link to comment
Share on other sites

// The mistake you make, is very common

// you forgot to include the path, because the file 1.jpg does not exist

// in your current directory, but it exists in your upload_folder/1.jpg

while ($file = readdir($dir_handle)) {

  if ($file <> "." && $file <> "..") {

     $full = $path . DIRECTORY_SEPERATOR . $file;

     rename($full, strtoupper($full));

  }

}

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.