Art Alexion on 22 Feb 2006 16:50:14 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] bash script help needed


Michael C. Toren wrote:

>On Wed, Feb 22, 2006 at 09:39:56AM -0500, Art Alexion wrote:
>  
>
>>for OLD in *
>>  do
>>    NEW=`echo $OLD|sed s/\ /\_/g | tr [:upper:] [:lower:]`
>>    echo "OLD=\"$OLD\""
>>    echo "NEW=\"$NEW\""
>>    echo -e "mv \"$OLD\" \"$NEW\"\n"
>>    mv $OLD $NEW
>>  done
>>
>>But this results in the error
>>
>>mv: when moving multiple files, last argument must be a directory
>>    
>>
>
>Try replacing your "mv" line with:
>
>	mv -i "$OLD" "$NEW"
>
>  
>
This seems like a very good suggestion.

>To weed out additional whitespace characters, try changing your "sed"
>line to:
>
>	NEW=`echo $OLD | sed 's/[[:space:]]/_/g' | tr [:upper:] [:lower:]`
>
>which will catch both spaces, tabs, and newlines.
>  
>
And so did this, except it didn't work.  Error was

/home/arthur/rpl_spaces_only: command substitution: line 43: unexpected
EOF while looking for matching `''
/home/arthur/rpl_spaces_only: command substitution: line 44: syntax
error: unexpected end of file
OLD="Old Name - with spaces and parentheses.ext"
NEW=""
mv "Old Name - with spaces and parentheses.ext" ""

mv: cannot move `Old Name - with spaces and parentheses.ext' to `': No
such file or directory

>See also the "rename" command, which comes with perl.
>
>  
>
I didn't know I could use this on a batch, but I'll check it out.

-- 

_______________________________________
Art Alexion
Arthur S. Alexion LLC

PGP fingerprint: 52A4 B10C AA73 096F A661  92D2 3B65 8EAC ACC5 BA7A
The attachment -- signature.asc -- is my electronic signature; no need for alarm.
Info @ http://mysite.verizon.net/art.alexion/encryption/signature.asc.what.html

Key for signed PDFs available at
http://mysite.verizon.net/art.alexion/encryption/ArthurSAlexion.p7c
The validation string is TTJY-ZILJ-BJJG.
________________________________________

Attachment: signature.asc
Description: OpenPGP digital signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug