Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   rename (http://www.velocityreviews.com/forums/t885748-rename.html)

luc 04-04-2004 08:33 PM

rename
 
I frequently have to rename files like "MyPiCiNPaRiS.jpg" and I'm really
annoyed with the fact that sometimes there are hundreds of them. Is there a
program out there for xp that can help me automatically rename these files
into all small case?



Xaonon 04-04-2004 09:36 PM

Re: rename
 
Ned i bach <gi_bc.60595$3j2.3888172@phobos.telenet-ops.be>, luc
<anonymous@disneyland.com> teithant i thiw hin:

> I frequently have to rename files like "MyPiCiNPaRiS.jpg" and I'm really
> annoyed with the fact that sometimes there are hundreds of them. Is there
> a program out there for xp that can help me automatically rename these
> files into all small case?


$ perl -e 'rename $_, lc $_ for @ARGV' *.jpg

Add error code and checks for pre-existing files as appropriate.

--
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
http://xaonon.dyndns.org/ Guaranteed content-free since 1999. No refunds.
"Since I do things on a regular basis that defies the laws of physics, I can
speak with some authority on the matter." -- vtailor@gte.net, in alt.atheism

Bob Walton 04-05-2004 01:39 AM

Re: rename
 
Xaonon wrote:

> Ned i bach <gi_bc.60595$3j2.3888172@phobos.telenet-ops.be>, luc
> <anonymous@disneyland.com> teithant i thiw hin:

....


> $ perl -e 'rename $_, lc $_ for @ARGV' *.jpg



Uh, for Windoze, you'd better make it:

perl -e "rename $_,lc $_ for <$ARGV[0]>" *.jpg

or simply:

perl -e "rename $_,lc $_ for <*.jpg>"

--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


Xaonon 04-05-2004 03:18 AM

Re: rename
 
Ned i bach <4070B8A1.9030600@rochester.rr.com>, Bob Walton
<invalid-email@rochester.rr.com> teithant i thiw hin:

> Xaonon wrote:
>
> > Ned i bach <gi_bc.60595$3j2.3888172@phobos.telenet-ops.be>, luc
> > <anonymous@disneyland.com> teithant i thiw hin:

> ...
>
> > $ perl -e 'rename $_, lc $_ for @ARGV' *.jpg

>
> Uh, for Windoze, you'd better make it:
>
> perl -e "rename $_,lc $_ for <$ARGV[0]>" *.jpg
>
> or simply:
>
> perl -e "rename $_,lc $_ for <*.jpg>"


Now I remember why I always use Cygwin instead of the actual the Windoze
command line.

--
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
http://xaonon.dyndns.org/ Guaranteed content-free since 1999. No refunds.
You were an atheist. You were stridently aligned. You were poison resistant.
You were invisible. You were a werejackal. You were lucky. You are dead.

Xaonon 04-05-2004 03:20 AM

Re: rename
 
Ned i bach <4070B8A1.9030600@rochester.rr.com>, Bob Walton
<invalid-email@rochester.rr.com> teithant i thiw hin:

> Xaonon wrote:
>
> > Ned i bach <gi_bc.60595$3j2.3888172@phobos.telenet-ops.be>, luc
> > <anonymous@disneyland.com> teithant i thiw hin:

> ...
>
> > $ perl -e 'rename $_, lc $_ for @ARGV' *.jpg

>
> Uh, for Windoze, you'd better make it:
>
> perl -e "rename $_,lc $_ for <$ARGV[0]>" *.jpg
>
> or simply:
>
> perl -e "rename $_,lc $_ for <*.jpg>"


Now I remember why I always use Cygwin instead of the actual Windoze command
line.

--
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
http://xaonon.dyndns.org/ Guaranteed content-free since 1999. No refunds.
You were an atheist. You were stridently aligned. You were poison resistant.
You were invisible. You were a werejackal. You were lucky. You are dead.

Peter J. Acklam 04-05-2004 06:07 AM

Re: rename
 
Xaonon <xaonon@hotpop.com> wrote:

> $ perl -e 'rename $_, lc $_ for @ARGV' *.jpg
>
> Add error code and checks for pre-existing files as appropriate.


There is no point in checking for pre-existing files here, since
if "MyPiCiNPaRiS.jpg" exists, then "mypicinparis.jpg" exists, but
it is actually the same file.

Peter

--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;

Xaonon 04-05-2004 08:58 PM

Re: rename
 
Ned i bach <vfkf3qln.fsf@online.no>, Peter J. Acklam <pjacklam@online.no>
teithant i thiw hin:

> Xaonon <xaonon@hotpop.com> wrote:
>
> > $ perl -e 'rename $_, lc $_ for @ARGV' *.jpg
> >
> > Add error code and checks for pre-existing files as appropriate.

>
> There is no point in checking for pre-existing files here, since
> if "MyPiCiNPaRiS.jpg" exists, then "mypicinparis.jpg" exists, but
> it is actually the same file.


At least until someone tries to use the same code on a system where "foo"
and "Foo" are distinct files. That's what "as appropriate" means.

--
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
http://xaonon.dyndns.org/ Guaranteed content-free since 1999. No refunds.
"How benevolent of you! We will always be free to be stupid." "Cherish
that freedom, young master; it is basic to all others." -- The Golden Age

Peter J. Acklam 04-06-2004 06:45 AM

Re: rename
 
Xaonon <xaonon@hotpop.com> wrote:

> Peter J. Acklam <pjacklam@online.no>:
>
> > Xaonon <xaonon@hotpop.com> wrote:
> >
> > > $ perl -e 'rename $_, lc $_ for @ARGV' *.jpg
> > >
> > > Add error code and checks for pre-existing files as appropriate.

> >
> > There is no point in checking for pre-existing files here,
> > since if "MyPiCiNPaRiS.jpg" exists, then "mypicinparis.jpg"
> > exists, but it is actually the same file.

>
> At least until someone tries to use the same code on a system
> where "foo" and "Foo" are distinct files. That's what "as
> appropriate" means.


I know what "as appropriate" means. I was only pointing out
that in this case it was not appropriate, and why it was not
appropriate.

Peter

--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


All times are GMT. The time now is 05:58 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.