1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

changing 3000 file extensions at once

Discussion in 'PHP' started by Silver89, Dec 3, 2006.

  1. #1
    Hi,

    i have 3000 .cur files online and i need to change them all to .ani

    i have treid

    <?php rename("cursor/(.*?).cur", "cursor/(.*?).ani"); ?>

    but this was no success

    Please hlep thanks!
     
    Silver89, Dec 3, 2006 IP
  2. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Wrote a quick script.. I'm sure theres a better way to do it.. I haven't tested it so TEST IT BEFORE YOU USE IT

    
    <?php
    
            set_time_limit(0);
    
    	$dh = opendir("./");
    	
    	while (($files = readdir($dh))) {
    		if ($files == ".." || $files == ".") continue;
    		
    		if (ereg("(.*)\.cur", $files)) {
    		
    			echo "Renaming $files...<br />" . 
    			rename($files, substr($files, 0, -3) . "ani");
    			
    		} else {
    		
    			continue;
    			
    		}
    		
    	}
    
    ?>
    
    PHP:
    **EDIT** Added no time limit.. if 3000 files might hit 30 seconds.. not sure.
     
    CodyRo, Dec 3, 2006 IP
    Silver89 likes this.
  3. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #3
    great this worked first time many thanks
     
    Silver89, Dec 11, 2006 IP