Renaming files in bulk - plembo/onemoretech GitHub Wiki

Renaming files in bulk

These bash one-liners were used to lowercase and rename the profile and thumbnail images for a corporate directory application when a code change required: (a) they all be in lowercase; and (b) thumbnails get a _t.jpg extension.

For profile images directory:

for i in *; do mv $i `echo $i | tr [:upper:] [:lower:]`; done

To rename thumnails from "E10000001.jpg" to "e10000001_t.jpg":

for i in *.jpg; do mv "$i" "${i/.jpg}"_t.jpg; done

To lowercase all thumbails:

for i in *; do mv $i `echo $i | tr [:upper:] [:lower:]`; done

Copyright 2004-2019 Phil Lembo