Skip to content

Instantly share code, notes, and snippets.

@xkr47
Created February 24, 2014 08:44
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 xkr47/9183973 to your computer and use it in GitHub Desktop.
Save xkr47/9183973 to your computer and use it in GitHub Desktop.
Rename all *.sh files to *.pl: git mvs 's/\.sh$/.pl/' *.sh
#!/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