Last active
November 29, 2015 11:16
-
-
Save ahihi/9d46f22614efa9add194 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
if [ "$#" != 3 ]; then | |
echo "Usage: $0 <from> <to> <file>" | |
exit 1 | |
fi | |
FROM=$1 | |
TO=$2 | |
FILE=$3 | |
dirname=$(dirname "$FILE") | |
old_filename=$(basename "$FILE") | |
new_filename=${old_filename//$FROM/$TO} | |
if [ "$old_filename" != "$new_filename" ]; then | |
mv "$dirname/$old_filename" "$dirname/$new_filename" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment