Skip to content

Instantly share code, notes, and snippets.

@bluebanboom
Created January 20, 2013 14:19
Show Gist options
  • Save bluebanboom/4578993 to your computer and use it in GitHub Desktop.
Save bluebanboom/4578993 to your computer and use it in GitHub Desktop.
Simple batch rename shell
#!/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