Last active
December 17, 2015 16:49
-
-
Save sairion/5641708 to your computer and use it in GitHub Desktop.
Recursively change file name substring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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