fix-filenames
put this in your path, go to a directory that has filenames or directories with spaces or special characters, and execute.
#!/bin/bash
###############################################################################################
# 2014_05May_09 - john meister copyright 2014 http://LinuxMeister
# script to remove spaces in file names and replace with underscore
# cleans up web pages by eliminating special characters and allows sorts to work properly
# to use place this script in your path and make it executable, then cd to the directory
# and execute by the saved name (fix-filename) - works on Linux and MacOS
###############################################################################################
# removes spaces, special characters, slashes, and _-_ but NOT caps
###############################################################################################
for f in *
do
mv -v "$f" `echo $f | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | sed 's/&/-n-/g' | sed 's/_-_/_/g'`
done
|