Saturday, July 2, 2011

Ubuntu, renaming files recursively

As a result of researching how one can quickly (in one-liner) rename, on Linux (=Ubuntu in my case) all .JPG files in a directory tree to .jpg files, the following solution was found (borrowed from a discussion here after fixing the typo's :) ):
 find . -name *.JPG -exec rename 's/\.JPG$/\.jpg/i' {} +
It won't work on Mac though (a Mac user offered this one):
for i in `find . -name '*.JPG'`; do mv $i ${i/%JPG/jpg}; done

Thought it might be worth remembering :)