Skip to content

Instantly share code, notes, and snippets.

@graphbear
Created July 24, 2015 12:47
Show Gist options
  • Save graphbear/dcf40b8cdabc1e9416af to your computer and use it in GitHub Desktop.
Save graphbear/dcf40b8cdabc1e9416af to your computer and use it in GitHub Desktop.
clean special characters from file names
specChars () {
tr [:blank:] [_] | tr [/] [_] | tr -d [=~=][=!=][=@=][=#=][=$=][=%=][='('=][=')'=][=\'=][=,=][=.=][=:=][=';'=][=\\=]
}
IFS=$'\n'
files=$(ls -1)
for file in $files ; do
echo $file
newFile=$(specChars $file)
echo "$file" $newFile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment