From: Chris Koeritz Date: Mon, 30 Apr 2012 14:28:58 +0000 (-0400) Subject: new script, basically ripping off the bracket fixer. there's a more X-Git-Tag: 2.140.90~1371 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=9b7838e4daba218fe52c800af282fe05d24554a1;p=feisty_meow.git new script, basically ripping off the bracket fixer. there's a more general way to attack this issue. we kind of want to be able to chain a bunch of name changes together for different purposes. --- diff --git a/scripts/files/spaces_to_underscores.sh b/scripts/files/spaces_to_underscores.sh new file mode 100644 index 00000000..ebfbcff6 --- /dev/null +++ b/scripts/files/spaces_to_underscores.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# takes names given to it and replaces any spaces or other gnarly characters with underscores. + +#hmmm: this starts to look like a useful function that the bracket fixer could also use. + +if [ $# -lt 1 ]; then + echo "This script requires one or more file names whose names should be fixed." + echo "Any spaces or single-quote characters will be stripped out in a useful way." + exit 1 +fi + +while [ $# -gt 0 ]; do + file="$1"; shift + newname="$(echo "$file" | tr ' ' '_' | tr -d "'" | sed -e 's/\([0-9]\)_\./\1./g' )" + if [ "$file" != "$newname" ]; then + # we've effected a name change, so let's actually do it. + echo "moving '$file' => '$newname' " + mv "$file" "$newname" + fi +done +