Skip to content

Instantly share code, notes, and snippets.

@brain90
Created December 23, 2013 10:44
Show Gist options
  • Save brain90/8094936 to your computer and use it in GitHub Desktop.
Save brain90/8094936 to your computer and use it in GitHub Desktop.
strip non alpha numeric for multiple filenames.
#!/bin/sh
for old in *.mp3; do
new=$(echo $old | sed -e 's/[^a-zA-Z0-9\s\.]/_/g' | sed -e 's/_\+/_/g' | sed -e 's/_\./\./g')
mv -v "$old" "$new"
done
# Modified from:
# http://stackoverflow.com/questions/1961255/rename-files-using-a-regex-with-bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment