[brlug-general] Recursive batch rename
Ronnie Gilkey
ronnie at puryear-it.com
Tue May 13 09:29:39 CDT 2008
Joe,
I would try something along these lines -- for example if I needed to
make a backup of all my .pl files:
find /perldir -type f -name "*.pl" -exec cp '{}' '{}.bak' \;
This will copy all files in that directory and the subdirectory for you.
Ronnie Gilkey
ronnie at puryear-it.com
--
Puryear Information Technology, LLC
Baton Rouge, LA * 225-706-8414
http://www.puryear-it.com
Visit http://www.puryear-it.com/publications.htm to download your free
copies of:
"Best Practices for Managing Linux and UNIX Servers"
"Spam Fighting and Email Security in the 21st Century"
Alvaro Zuniga wrote:
> Joe,
>
> for i in $(find . -type f); do mv $i $i.old; done;
>
> This should work from the command line. I also learned from a previous post
> about the rename command. This line however, should be the basis for many
> future scripts.
>
> Needless to say, be extremely careful, I am afraid I know the destructive
> powers of this line first hand. It all happened a few years ago; I forgot to
> be careful. My therapist says that I must learn to let go.
>
> Alvaro Zuniga
>
> On Tuesday 13 May 2008 08:58:08 Joe Fruchey wrote:
>
>> This is a silly script question, but I've never done much scripting,
>> so help me out here.
>>
>> I have this simple renaming script, say
>>
>> for i in $(ls); do (mv $i $i.old); done
>>
>> How do I make this thing run in all subdirectories? I'm guessing I
>> have to define it as a function and have a script traverse the
>> directories, but I don't know how.
>>
>> Help?
>>
>> -Joe
>>
>> _______________________________________________
>> General mailing list
>> General at brlug.net
>> http://mail.brlug.net/mailman/listinfo/general_brlug.net
>>
>
>
>
> _______________________________________________
> General mailing list
> General at brlug.net
> http://mail.brlug.net/mailman/listinfo/general_brlug.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.brlug.net/pipermail/general_brlug.net/attachments/20080513/368e4037/attachment.html
More information about the General
mailing list