Published in: Bash
This small, bash script will loop though the specified files and rename them according to a sed regular expression. In this example, I'm renaming a bunch of .avi movie files.
for i in *.avi do j=`echo $i | sed 's/find/replace/g'` mv "$i" "$j" done Can also be written on a single line as for i in *.avi; do j=`echo $i | sed 's/find/replace/g'`; mv "$i" "$j"; done
Comments
Subscribe to comments
You need to login to post a comment.

prename is much simpler, and it is in the perl standard distributio that is installed in almost all unix systems. to use it: prename 's/find/replace/ files
enjoy