#!/bin/sh # noamp-files -- rename files with spaces in their names with underscores # and ampersands to minus signs # # AUTHOR: Gary T. Leavens [ -n "$echo" ] && set -x USAGE='$0 [filename] ...' ret=0 if test $# -eq 0 then while read f do NEWNAME=`echo "$f" | tr '& ' '-_'` if test -f "$NEWNAME" then echo "not renaming $f, as $NEWNAME exists!" 2>&1 ret=1 else # echo "renaming $f as $NEWNAME ..." mv "$f" "$NEWNAME" || ret=1 fi done else for f do NEWNAME=`echo "$f" | tr '& ' '-_'` if test -f "$NEWNAME" then echo "not renaming $f, as $NEWNAME exists!" 2>&1 ret=1 else echo "renaming $f as $NEWNAME ..." mv "$f" "$NEWNAME" || ret=1 fi done fi exit "$ret"