#!/bin/bash # # Syntax: mvnospaces [-h] file [...] # # Purpose: Converts the spaces in the given filenames to underscores. # The -h flag shows the help info for this command. # Created: Jul 15, 2003 by Bart De Schutter # Last revised: Jul 26, 2007 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: files if [ $# -ge 1 -a "$1" = "-h" ]; then sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi if [ $# -eq 0 ]; then echo >&2 echo >&2 "ERROR: ${0##*/} requires at least 1 input argument." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi for fname in "$@" do if [ -e "$fname" ]; then lname=$(echo "$fname" | tr " " "_") \mv "$fname" "$lname" else echo >&2 "WARNING: file or directory $fname not found." fi done