JSHINER Posted August 19, 2008 Share Posted August 19, 2008 I have a directory of files: 001949.flv.mp4 001958.flv.mp4 etc... How could I create a script to automatically rename all the files in the directory to .mp4 and get rid of the .flv so they would now be: 001949.mp4 001958.mp4 etc... Link to comment https://forums.phpfreaks.com/topic/120368-renaming-files-in-a-directory/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 19, 2008 Share Posted August 19, 2008 <?php foreach (glob("*.mp4") as $filename) { rename($filename,str_replace(".flv.",".",$filename)); } ?> Link to comment https://forums.phpfreaks.com/topic/120368-renaming-files-in-a-directory/#findComment-620150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.