Skip to content

Instantly share code, notes, and snippets.

@bdcravens
Created February 16, 2013 16:41
Show Gist options
  • Save bdcravens/4967610 to your computer and use it in GitHub Desktop.
Save bdcravens/4967610 to your computer and use it in GitHub Desktop.
was: Invoice_000000ABCDEF012_010113.csv changeto: ABCDEF012.csv (leading zeros may change)
#!/bin/bash
FILES=Invoice_*_*.csv
for f in $FILES
do
newname=`echo $f| cut -d'_' -f 2`
newnamelen=${#newname}
leading=$[newnamelen-9]
invnum=${newname:leading}
mv $f $invnum.csv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment