rename mass files from the web directory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    rename mass files from the web directory

    Hello

    I need a script to mass rename files names from my server
    if you know any good script for it
    please suggest the name or if possible share it here


    Thanks in advance!
    Buying mobile traffic, PM me with your traffic details

    #2
    PHP Code:
    <?php

    $dir 
    'files';
    $search 'text_in_filename_which_you_want_to_rename';
    $new ='String_to_replace_the_search_string';
    $paths = array();

    $i = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));

    while(
    $i->valid()) {

        if (!
    $i->isDot()) {

            
    $subpath $i->getSubPath();

            if (
    $subpath != '') {
                
    // if inside a subdirectory
                // add the subpath in our array flagging it as false
                
    if (!array_key_exists($subpath$paths))
                         
    $paths[$subpath] = false;

                
    // check if it's our file
                
    if (strstr(($i->getSubPathName()),$search)
                  {
                    
    $n=str_replace($search,$new,$i->getSubPathName());
                                echo 
    $i->getSubPathName().'<br/>';
                        
    rename($dir.'/'.$i->getSubPathName(),$dir.'/'.$n);                
                   }

        }

        
    $i->next();
    }
    }

    ?>

    Comment

    Working...
    X