Created
January 20, 2013 14:19
-
-
Save bluebanboom/4578993 to your computer and use it in GitHub Desktop.
Simple batch rename shell
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 | |
# simple batch rename | |
cmd="" | |
ext="" | |
if [ "$#" -eq 1 ]; then | |
ext=$1 | |
cmd="ls *."$ext | |
else | |
echo "usage:$0 ext" | |
fi | |
n=1 | |
for file in `$cmd` | |
do | |
echo "mv $file to $n.$ext" | |
mv $file $n"."$ext | |
let "n = $n + 1" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment