note 111381 deleted from function.rename by cmb

From: Date: Sun, 22 Dec 2019 09:06:26 +0000
Subject: note 111381 deleted from function.rename by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213591@lists.php.net to get a copy of this message
Note Submitter: asdf at NOSPAM dot serverwg dot net ---- a simpler code for changing file extentions of multiple files in your working directory. #!/usr/bin/php <?php //What? Quick CLI-tool to rename the file extensions of multiple files (in working directory) matching the pattern. //Author? ZuZi //Date? 2013/02/14 if($argv[1] && $argv[2]){ foreach (glob("*.$argv[1]") as $filename) { echo ("change $filename to ".substr($filename,0,-(strlen($argv[1])))."$argv[2]\n"); rename("$filename", substr($filename,0,-(strlen($argv[1])))."$argv[2]"); } }else exit("\nERROR: ARGUMENTS MISSING!\n\nChanges the extension of all files matching <source> to <target>, in working directory.\n usage: changeFileType source target \n\n"); ?>

« previous php.notes (#213591) next »