Bulk file renaming in Linux
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'.
- Previous: One thousand miles
- Next: Problems With 110mb.com?