Created
December 19, 2014 10:41
-
-
Save wancw/23486e650cc8d7041d42 to your computer and use it in GitHub Desktop.
Run rename(1) recursively
This file contains hidden or 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
#!/bin/sh | |
TARGET_DIR="$1" | |
shift | |
FROM="$1" | |
shift | |
TO="$1" | |
shift | |
if [[ "$*" != "" ]]; then | |
RENAME_ARGS="$*" | |
else | |
RENAME_ARGS="-n" | |
fi | |
echo f d | xargs -n 1 -I = echo find "$TARGET_DIR" -type = -exec rename -e "s/$FROM/$TO/g" $RENAME_ARGS '{}' ';' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment