Friday, February 27, 2009

Batch rename files with bash

How to batch rename files in a one-line bash script:

for f in *.txt; do mv ./"$f" "$f.newname"; done

and the other direction:

for f in *.mine; do mv $f `echo $f | sed 's/\(.*\).newname/\1/'`; done

From this post.

No comments: