need script

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: George Toft
Date:  
Subject: need script
You'll have to enclose $FILE in quotes in the mv command,
otherwise you'll get something like this:\
FILE <- Some File
LOWER <- some_file
mv Some File some_file (which will blow up)

Try:
mv "$FILE" $LOWER


I verified this as shown:
[georgetoft@biff tmp]$ ls -l
total 0
-rw-r--r--    1 georgeto georgeto        0 Apr 25 08:49 Some File
[georgetoft@biff tmp]$ echo $FILE $LOWER
Some File some_file
[georgetoft@biff tmp]$ mv $FILE $LOWER
mv: when moving multiple files, last argument must be a directory
[georgetoft@biff tmp]$ mv "$FILE" $LOWER
[georgetoft@biff tmp]$ ls -l
total 0
-rw-r--r--    1 georgeto georgeto        0 Apr 25 08:49 some_file
[georgetoft@biff tmp]$


George



Kurt Granroth wrote:

> wrote:
>
>> Certainly someone must have a script (preferably Perl)
>> laying around somewhere that will:
>>
>> Recurse thru directories and rename files by replacing
>> any UPPER case characters with lower and replacing spaces
>> in the file names with something like underscores.
>
>
> Off the top of my head, this might work:
>
>  #!/bin/sh
>  FILES=`find -type f`;
>  for FILE in $FILES;
>  do
>    LOWER=`echo $FILE | tr 'A-Z ' a-z_`;
>    mv $FILE $LOWER;
>  done

>
> Not tested and won't work if your directories have upper case letters
> or spaces.