Created
February 24, 2014 08:44
-
-
Save xkr47/9183973 to your computer and use it in GitHub Desktop.
Rename all *.sh files to *.pl: git mvs 's/\.sh$/.pl/' *.sh
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 [ $# -lt 1 ]; then | |
echo usage: "$0 <perl> [<file1> ...]" | |
exit 1 | |
fi | |
sed="$1" | |
shift | |
try () { | |
if ! "$@" ; then | |
echo ERROR!! | |
exit 1 | |
fi | |
} | |
for old ; do | |
new="`echo -n $old | perl -pe "$sed"`" | |
if [ "$old" = "$new" ]; then | |
echo "Filename unchanged: $old" | |
else | |
echo "$old -> $new" | |
mkdir -p "`dirname \"$new\"`" | |
try git mv "$old" "$new" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment