X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Ffiles%2Freplace_spaces_with_underscores.sh;h=3cbcfa89a84326537abe3430930e217fb848a4cf;hb=f7b8b07c068d009b92e76566e6e20221f82d772f;hp=375b827457ef208e338fe3e7e5773a13334aaa4c;hpb=78d8d62332226c326575de341f613a29f3a98151;p=feisty_meow.git diff --git a/scripts/files/replace_spaces_with_underscores.sh b/scripts/files/replace_spaces_with_underscores.sh index 375b8274..3cbcfa89 100644 --- a/scripts/files/replace_spaces_with_underscores.sh +++ b/scripts/files/replace_spaces_with_underscores.sh @@ -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'"