Recursive Batch Rename in Console

ratpoison_logo-60

One quick one for the end of the year…
Recursive batch rename of directories and files in the same time:

#replace ” ” with “.”:
find . -depth -name '* *' -execdir bash \-c 'a="{}";mv -f "$a" ${a// /.}' \;

#replace “-” with “_”:
find . -depth -name '*-*' -execdir bash \-c 'a="{}";mv -f "$a" ${a//-/_}' \;

#replace “if” with “or”:
find . -depth -name '*if*' -execdir bash \-c 'a="{}";mv -f "$a" ${a//if/or}' \;

…if you want to rename just directories or files just add:

-type d #for directories
-type f #for files

…after…
-depth

Happy New Year….

Advertisements

One response to “Recursive Batch Rename in Console

  1. Pingback: 1p – Recursive Batch Rename in Console – Exploding Ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s