Art Alexion on 9 Sep 2005 14:20:32 -0000


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

Re: [PLUG] batch renaming


Thomas Thurman wrote:

>Art Alexion said:
>  
>
>>in dos if I wanted to rename a batch of files i a directory, I could do
>>
>>    move (or rn) ??.txt 61??.txt
>>
>>and it would rename all of the two character-named text files to prepend
>>61.  Bash won't let me do this as
>>
>>    mv ??.txt 61??.txt
>>    
>>
>
>The reason this doesn't work is the way wildcards are expanded in the
>shell. Suppose you have aa.txt, bb.txt and cc.txt in the current
>directory. Then in
>
>  mv ??.txt 61??.txt
>
>the "??.txt" gets expanded to the names of all the files it matches, i.e.
>"aa.txt bb.txt cc.txt", but the "61??.txt" doesn't match any files in the
>current directory, so it ends up as an empty string. So what mv finally
>sees is:
>
>  mv aa.txt bb.txt cc.txt
>
>hence your error about "target must be a directory".
>
>  
>
>>Is there a command that will let me do this?
>>    
>>
>
>It's not in all installations, but you might find that you have Larry
>Wall's "rename" command available. It takes a regular expression and a set
>of filenames. So in your case you'd write
>
>  rename 's/^/61/' ??.txt
>
>  
>
I didn't realize, but I do have "rename".  I will have to keep my perl
expression reference open until I get used to it.  Thanks.

-- 

_______________________________________
Art Alexion
Arthur S. Alexion LLC
arthur [at] alexion [dot] com
aim: aalexion
sms: 2679725536 [at] messaging [dot] sprintpcs [dot] com

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