Re: rename files challenge...

Kezdőlap
Csatolmányok:
Üzenet email-ben
+ (text/plain)
+ signature.asc (application/pgp-signature)
+ (text/plain)
Üzenet törlése
Válasz az üzenetre
Szerző: June Tate
Dátum:  
Címzett: Main PLUG discussion list
Tárgy: Re: rename files challenge...
On Fri, Aug 19, 2005 at 09:17:11AM -0700, Craig White wrote:
> # find . -name "*%*.*"
>
> locates them, how do I pass them to a mv command to rename them without
> the '%' sign (I want to take the percent sign out of the filenames)?
>
> how about if I want to replace the % with an underscore?


Try something like this:

    foo@bar:~$ for i in $(find . -name "*%*.*"); do \
    > newname=$(echo $i |sed s/%/_/); \
    > mv $i $newname; \
    > done


This grabs the entire list of files and for each file in the list
generates a new filename by replacing the % with an _, and then mv-ing
it.

Hope that helps. =o)

--
June Tate * http://www.theonelab.com *
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss