Jeff D <[EMAIL PROTECTED]>: > On Tue, 17 Apr 2007, Masatran, R. Deepak wrote: > > Since I frequently receive files from Microsoft Windows users, is there any > > utility to unix-ify file names, that is, use lower case exclusively, use > > hyphen as separator, etc.? [...] > #!/bin/sh > #change spaces to hyphens > rename 's/\ /-/g' *$1 > > #uppercase to lower > for FILE in `ls *$1` ; do
Please don't teach beginners to do for loops like this. It's broken in various ways. Just do: for FILE in *"$1" ; do > filename=`basename $FILE` > newfile=`echo $filename | tr A-Z a-z` > if [ "$filename" != "$n" ] ; then > mv $filename $newfile Maybe adding '-i' to the mv call would be a good idea to avoid accidentally overwriting existing files. > fi > done [...] Regards, Frank -- In protocol design, perfection has been reached not when there is nothing left to add, but when there is nothing left to take away. -- RFC 1925 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]