Jump to content

So is rename() failing or not?


Voldemort

Recommended Posts

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

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.