gunesahmet Posted January 22, 2010 Share Posted January 22, 2010 <?php $dir='./'; $up=3; $w='.png'; $n=''; $prefix=''; $postfix=''; $replace=''; $replace_with=''; $tr=false; set_time_limit(120); $files=array(); error_reporting(E_ERROR | E_PARSE); function prep($f,$dir) { global $up,$prefix,$postfix,$w,$replace_with,$replace,$n,$files; if(strpos($f,$n)!==false) return $f; $f=str_replace($replace,$replace_with,$f); if($up==1) $f=strtoupper($f); elseif($up==2) $f=strtolower($f); $f=$prefix.$f.$postfix; $files[]=$dir.$f; return $f; } $i=0; function dir_tr($dir) { global $i,$w,$tr,$files; $dir=rtrim(trim($dir,'\\'),'/') . '/'; $d=@opendir($dir); if(!$d)die(.$dir . 'Klasorundeki ' ' dosyalarin PHP icin yetkisi yok'); while(false!==($file=@readdir($d))) { if ($file!='.' && $file!='..' && $file!='renamer.php') { if(is_file($dir.$file)) { if($w=='' || (strpos($file,$w)!==false)) { if(!in_array($dir.$file,$files)) { rename($dir.$file,$dir.(prep($file,$dir))); $i++; } } } else { if(is_dir($dir.$file)) { if($tr) dir_tr($dir.$file); } } } } @closedir($d); } dir_tr($dir); echo '<br> '.$i.' klasorundeki dosyalar yeniden adlandirildi<br>' . $dir; echo "<br>Simdi renameri silmen gerekiyor "; ?> Dont rename files this script please help me !!! Link to comment https://forums.phpfreaks.com/topic/189486-what-is-it-wrong-in-this-rename-script/ Share on other sites More sharing options...
JREAM Posted January 22, 2010 Share Posted January 22, 2010 For starters there is no code commenting and takes 4x as along to read through Link to comment https://forums.phpfreaks.com/topic/189486-what-is-it-wrong-in-this-rename-script/#findComment-1000160 Share on other sites More sharing options...
jl5501 Posted January 22, 2010 Share Posted January 22, 2010 PHP passes function parameters by value, not by reference, so when you pass your $dir value into the function it works on a copy of the variable, not the original. So, when the function returns, the original value of $dir will be unchanged. Link to comment https://forums.phpfreaks.com/topic/189486-what-is-it-wrong-in-this-rename-script/#findComment-1000181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.