#!/bin/sh # Convert spaces to underscores in the arguments. # # Author: R.F. Smith # Time-stamp: <2011-03-07 21:57:44 rsmith> # # To the extent possible under law, Roland Smith has waived all copyright and # related or neighboring rights to 'nospaces'. This work is published from the # Netherlands. See http://creativecommons.org/publicdomain/zero/1.0/ # Check for arguments if [ $# -eq 0 ]; then echo "Usage: $(basename $0) filename(s)" exit 1 fi for f in "$@"; do NEWNAME=$(echo "$f"|sed -Ee 's/[ ()]+/_/g' -e 's/_\./\./g') if [ "$f" != "$NEWNAME" ]; then # echo "Moving '$f' to '$NEWNAME'" mv "$f" $NEWNAME # else # echo "Skipping '$f'; no whitespace" fi done