Voldemort Posted June 10, 2008 Share Posted June 10, 2008 Here's my code. Example variable definitions follow. if(!empty($files)) foreach($files as $file){ if(is_dir($dir . "\\" . $file['album']) || @mkdir($dir . "\\" . $file['album'])) $text .= ' Folder <tt style="color:green;font-weight:bold;">' . dirname($file['new']) . '</tt> created or exists!<br />'; $renamed = @rename($file['old'], $file['new']); if($renamed) $text .= ' Couldn\'t rename <tt style="color:red;font-weight:bold;">' . $file['old'] . '</tt><br />'; else $text .= ' Done with <tt>' . $file['new'] . '</tt><br />'; } $dir - "C:\Documents and Settings\Steven\Shared\A-Ha" $file['old'] - "C:\Documents and Settings\Steven\Shared\A-Ha\Take On Me.mp3" $file['new'] - "C:\Documents and Settings\Steven\Shared\A-Ha\Hunting High and Low\Take On Me.mp3" $file['album'] - "Hunting High and Low" $files - an array of files... Sometimes it works, sometimes it doesn't. Thing is... it always says it doesn't work. Not once has it taken credit for actually achieving something! And I'd like to know if there's a way to make sure it'll work almost every time, instead of it being a crapshoot. Link to comment https://forums.phpfreaks.com/topic/109516-so-is-rename-failing-or-not/ Share on other sites More sharing options...
bluejay002 Posted June 10, 2008 Share Posted June 10, 2008 i think its an unhandled character problem... say special characters. try using addslashes() before writing. does it helps? Link to comment https://forums.phpfreaks.com/topic/109516-so-is-rename-failing-or-not/#findComment-561765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.