Notes From James
Home | About | Download
Bulk file renaming in Linux Saturday, August 8, 2009, 5:54 pm

I wanted to rename a bunch of files in Linux (m4v to mp4), but couldn't find any tools that I really liked, or understood. So, I wrote a quick script to rename files recursively. Here is the script:

find * | gawk -f ren_mp4.awk > runme
./runme

If you want to test it out, comment out or delete the './runme' line. The ren_mp4.awk file is:

/m4v/ { name = $0;
newname = $0;
gsub( "m4v", "mp4", newname );
cmd = "mv '" name "' '" newname "'";
print cmd }

Not terribly beautiful, but understandable. The 'gsub' command replaces occurrences of 'm4v' with 'mp4'.

Tags: Linux, Technology
No Comments
Comment
Your Name:
Web site (i.e. www.xxx.com):
Antispam: Type 'pizza' backwards:
Comment:


[Problems With 110mb.com?]  [One thousand miles]  
Important Stuff
Ghofulpo.com
Bike to Work Week

Friends
Peter PoP
Sneakatron

Latest Posts

Find Stuff
By Date, tags, etc.

Commands
Home
RSS
Index
Login