Help about mass renamer

Started on the old forum in September 2011 · view the original in the archive · old links redirect here

7 replies · 1,319 views · started 15 years ago · 1 min read

4 participants
surajpawaar Junior · 49 posts #1

i have vps hosting in x10hosting.com my site is surajmob.in when i try to rename files script say that rename was successfull but actually not any reflect can anyone help me about this

surajpawaar Junior · 49 posts #3

here is code

<?php 
///Mass Renamer/// 

// the directory 
// './' - is the current directory 
// '../' - is the parent directory 
// case sensitive 
// e.x.: /home/user or c:\files 
$dir='./'; 

// 1 - uppercase all files 
// 2 - lowercase all files 
// 3 - do not uppercase or lowercase 
$up=3; 

//rename files that have $w in their filename 
//case sensitive 
//set to '' if you want to rename all files 
$w=''; 

//do not rename files having $n in their filename 
$n=''; 

//add prefix to files 
$prefix=''; 

//add postfix 
$postfix=''; 

//replace 
$replace='MirChi.Mobi'; 
$replace_with='SurajMob.In'; 

//true - traverse subdirectories 
//false - do not traverse subdirectories 
$tr=true; 

////// do NOT change anything below this ///////// 
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('The directory ' .$dir .' does not exists or PHP have no access to it<br><a target="_blank" href="http://phpadda.in">Need help?</a>'); 

        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>Renamed ' . $i . ' files in directory<br>' . $dir; 
echo "<br>You can now delete renamer.php"; 
?>
phpnoob Junior · 14 posts #4

seems like its either permission or ownership matters of the files ...

change the ownership of files to default account .

Pflash Developer · 170 posts #5

lol u have to update ur database to see the effect.

surajpawaar Junior · 49 posts #6

i have run this script in 755,777 but nothing happen and pflash do u think am i fool grrrrrrrrrrrrrrrrrrrrrrrrrr😠

phpnoob Junior · 14 posts #7

surajpawaar wrote: i have run this script in 755,777 but nothing happen

try to change the ownership of the files from root to default account you are using

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close