Mass renaming files

Nice little shell one-liner to mass rename foo*.jpg to bar*.jpg

ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh

Leave off the last pipe to get a preview of the output first ;)

Heres a variation I used to keep just the first part of a file name before the first space (i.e. when Finder makes a copy of a file say)

l -1 *.jpg | awk '{print("mv \""$0"\" "$1".jpg")}' | /bin/sh

Comments are closed.