Skip to content

Instantly share code, notes, and snippets.

@sairion
Last active December 17, 2015 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sairion/5641708 to your computer and use it in GitHub Desktop.
Save sairion/5641708 to your computer and use it in GitHub Desktop.
Recursively change file name substring
#from http://serverfault.com/a/226717
#change all filename contains *string1* into *string2*
#change filename recursively
find . -name "*string1*" -exec sh -c 'mv "$1" "$(echo "$1" | sed s/string1/string2/)"' _ {} \;
#preview the command which will be excuted
find . -name "*string1*" -exec sh -c 'echo mv "$1" "$(echo "$1" | sed s/string1/string2/)"' _ {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment