Skip to content

Instantly share code, notes, and snippets.

@ahihi
Last active November 29, 2015 11:16
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 ahihi/9d46f22614efa9add194 to your computer and use it in GitHub Desktop.
Save ahihi/9d46f22614efa9add194 to your computer and use it in GitHub Desktop.
#!/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