[BASH][HELP] Can someone help me write a script to rename files? - Programming On Unix

Users browsing this thread: 1 Guest(s)
venam
Administrators
Use find with -iname to use a regex to get all the files you want.

Then add a -exec at the end of find to mv the file.

That would look like:
Code:
find location -maxdepth 1 -iname "regex here" -exec mv {} $(subquery here) \;

And the subquery would do the following:
Code:
The Mentalist Season 1 E(1).avi
Replace "eason " by "0" or nothing depending on how you want it.
Code:
The Mentalist S1 E(1).avi
Replace" E(" by "E", and ")" by nothing.
Code:
The Mentalist S1E1.avi

The hard part it to replace 1 digits number by 0 concatenated with the number.


Messages In This Thread
RE: [BASH][HELP] Can someone help me write a script to rename files? - by venam - 06-09-2014, 05:45 AM