Skip to content

Instantly share code, notes, and snippets.

@allanesquina
Created January 13, 2015 11:21
Show Gist options
  • Save allanesquina/82326118e9dcd73974e2 to your computer and use it in GitHub Desktop.
Save allanesquina/82326118e9dcd73974e2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# ./renamefiles.sh directory
#
ls *$1 | egrep 'regex here+' \
| while read f
do
# if you need remove some character
tna=$(echo $f | sed 's/regex here//')
echo "$1/$f" "$1/$tna"
# mv "$1/$f" "$1/$tna"
# if you need replace some character
echo "$1/$f" "$1/${f/old/new}"
# mv "$1/$f" "$1/${tna/old/new}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment