pan-users
[Top][All Lists]
Advanced

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

[OT] On renaming files - was [Pan-users] 0.11.3 question


From: Wolf J. Flywheel
Subject: [OT] On renaming files - was [Pan-users] 0.11.3 question
Date: Tue, 27 May 2003 19:06:36 -0400
User-agent: KMail/1.5.2

On Tuesday 27 May 2003 17:19, John Aldrich wrote:

> > >> for f in *.jpg ; do mv "${f}" "BobsCat${f}" ; done
> > >
> > > Those quotes and squiggly-brackets are unnecessary AFAIK.
> > >
> > >   for i in `ls *.jpg` ; do mv $i BobsCat$i; done
> > >
> > > is fine.
> >
> > You can get into some "deep shit" if you remove the quotes and the
> > filename has spaces in it. =)

        Yes, and that's why I wrote it.  Eric's solution is indeed fine for the 
case of no spaces or other odd characters; mine will work for that and 
files named "Bob's Cat & my Dog #3.jpg".  ;)

> Here's a handy little perl script someone whipped up to convert spaces
> to "_" in filenames for me.... I'm sure a good perl monger could make
> it a bit more robust and do more things much like was asked for
> originally... ;-) -=-=-=-=-=-=-

        Mmmmm... Perl!  For another way to get to the same place, you can also 
use the ${name//pattern/replace} in Bash.  Thus:

for f in *.jpg ; do echo mv "${f}" "BobsCat${f//\ /_}" ; done

        (Replace all spaces in any filename with _, and prepend "BobsCat" to 
all 
names.  Remove "echo" above for full functionality.  ;)  Somewhere I have 
a script I wrote that removes spaces, HTML-encoded spaces ("%20"), 
*double* spaces, and some other junk; if someone wants that I can find it 
and send or post it.

        BTW, entirely in the other direction, for those who'd like to rename 
tons 
of files graphically, there's a utility called "krename" 
(www.krename.net) that can do it even using embedded mp3/vorbis tags.  At 
last, a way to get all of my music files into my naming-convention of the 
month!  I'll be going to check it out after posting this.

Now that's enough off-topic-ness from me...

-- 
// Carl Hudkins :: ICQ 5723399 :: PGP 50238D9E
//
// ** Please support public radio! **
// **         www.wncw.org         **

Attachment: pgpWnRBFtIIHP.pgp
Description: signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]