Moving files

pll at lanminds.com pll at lanminds.com
Mon Jan 6 13:02:06 EST 2003


In a message dated: Mon, 06 Jan 2003 12:44:07 EST
Kevin D. Clark said:

>pll at lanminds.com writes:
>
>> 	perl -e 'opendir DIR,".";@f = grep { ! /^\./ && -f $_ } readdir(DIR);\
>> 	  map {($n = $_)=~ s/\s+/_/g; rename ($_, $n) } @f;'
>
>Things that come to mind when I see this:
>
>1:  this code doesn't recurse.

It wasn't intended to, it was intended to replace the OPs shell 
script which hosed him because of non-quoted, space-riddled, file 
names.  His shell script didn't recurse either (though I'm sure that 
the OP has cursed and re-cursed since starting this thread ;)

>2:  this code skips over files with a name that begins with ".".
>    (". foo" doesn't get touched)

Type, I should have used ! /^\.+$/  to indicate files which began 
with one or more '.'s and ended with same.
(that, and the OP mentioned using mp3 files, and I haven't seen too 
many mp3 files ^\.+ :)

>3:  this code doesn't rename directory names with spaces (I have quite
>    a few MP3 directories like this -- I don't know if this is
>    important to the original poster or not).

No, it doesn't, and wasn't meant to.  I agree it's a useful feature, 
and I like yours better.  Mine was simple meant to replace the 
existing shell script with a perl one liner that was easy to 
understand.  Most people new to perl I feel might get a little 
overwhelmed with something like the -MFile::Find call.  Maybe not, I 
don't know.

-- 

Seeya,
Paul
--
Key fingerprint = 1660 FECC 5D21 D286 F853  E808 BB07 9239 53F1 28EE

	It may look like I'm just sitting here doing nothing,
   but I'm really actively waiting for all my problems to go away.

	 If you're not having fun, you're not doing it right!





More information about the gnhlug-discuss mailing list