nice new tool to show version of feisty meow
[feisty_meow.git] / scripts / files / replace_spaces_with_underscores.sh
index 3f26f6a0920a4072e119f93d74d40e9b612e6540..3cbcfa89a84326537abe3430930e217fb848a4cf 100644 (file)
@@ -12,7 +12,11 @@ fi
 
 while [ $# -gt 0 ]; do
   file="$1"; shift
-  newname="$(echo "$file" | tr -s ' ' '_' | tr -d "\$@#%}{)(][\\\~',:?><\"" | sed -e 's/\([0-9]\)_\./\1./g' | sed -e 's/_-_/-/' )"
+  # first turn spaces into underscores.  then process characters we don't want
+  # in names.  then translate multiple underscores into just one.  then turn
+  # number followed by underscore into just number (?).  then translate
+  # underscore dash underscore into just dash.
+  newname="$(echo "$file" | tr -s ' ' '_' | tr -d "\$\!|@&#%}{)(][\\\~',:?><\"" | sed -e 's/__/_/g' | sed -e 's/\([0-9]\)_\./\1./g' | sed -e 's/_-_/-/' )"
   if [ "$file" != "$newname" ]; then
     # we've effected a name change, so let's actually do it.
     echo "'$file' => '$newname'"