Skip to content

Instantly share code, notes, and snippets.

@raym
Created March 29, 2015 20:02
Show Gist options
  • Save raym/cdadeecf6a0245cd23da to your computer and use it in GitHub Desktop.
Save raym/cdadeecf6a0245cd23da to your computer and use it in GitHub Desktop.
mv all files in a directory with a particular extension -- remove dashes, underscores, spaces, dots (add more if you like) and lowercase the filename
#!/bin/bash
ext=.png
for file in *$ext; do
baseName=${file%$ext}
baseNoDashes=$(echo $baseName | tr -d '_- .')
baseLower=$(echo $baseNoDashes | tr '[:upper:]' '[:lower:]')
fileNew=$baseLower$ext
echo Renaming $file to $fileNew
#mv $file $fileNew #uncomment to actually do it
done
@raym
Copy link
Author

raym commented Apr 4, 2015

thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment