Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > rename

Reply
Thread Tools

rename

 
 
luc
Guest
Posts: n/a
 
      04-04-2004
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?


 
Reply With Quote
 
 
 
 
Xaonon
Guest
Posts: n/a
 
      04-04-2004
Ned i bach <gi_bc.60595$(E-Mail Removed)-ops.be>, luc
<(E-Mail Removed)> 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." -- http://www.velocityreviews.com/forums/(E-Mail Removed), in alt.atheism
 
Reply With Quote
 
 
 
 
Bob Walton
Guest
Posts: n/a
 
      04-05-2004
Xaonon wrote:

> Ned i bach <gi_bc.60595$(E-Mail Removed)-ops.be>, luc
> <(E-Mail Removed)> 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

 
Reply With Quote
 
Xaonon
Guest
Posts: n/a
 
      04-05-2004
Ned i bach <(E-Mail Removed)>, Bob Walton
<(E-Mail Removed)> teithant i thiw hin:

> Xaonon wrote:
>
> > Ned i bach <gi_bc.60595$(E-Mail Removed)-ops.be>, luc
> > <(E-Mail Removed)> 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.
 
Reply With Quote
 
Xaonon
Guest
Posts: n/a
 
      04-05-2004
Ned i bach <(E-Mail Removed)>, Bob Walton
<(E-Mail Removed)> teithant i thiw hin:

> Xaonon wrote:
>
> > Ned i bach <gi_bc.60595$(E-Mail Removed)-ops.be>, luc
> > <(E-Mail Removed)> 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.
 
Reply With Quote
 
Peter J. Acklam
Guest
Posts: n/a
 
      04-05-2004
Xaonon <(E-Mail Removed)> 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;
 
Reply With Quote
 
Xaonon
Guest
Posts: n/a
 
      04-05-2004
Ned i bach <(E-Mail Removed)>, Peter J. Acklam <(E-Mail Removed)>
teithant i thiw hin:

> Xaonon <(E-Mail Removed)> 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
 
Reply With Quote
 
Peter J. Acklam
Guest
Posts: n/a
 
      04-06-2004
Xaonon <(E-Mail Removed)> wrote:

> Peter J. Acklam <(E-Mail Removed)>:
>
> > Xaonon <(E-Mail Removed)> 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;
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox Bookmark Rename and Thunderbird NG Questions Teather Mitty Firefox 4 12-26-2004 12:36 AM
New To Perl :- Help with "rename" and "File locking" Hugz Perl 3 02-25-2004 06:21 AM
Re: Best route to Rename a Domain.... Laura A. Robinson MCSE 0 09-19-2003 02:31 PM
Re: Rename a web form, error - missing some other reference? Kathy Burke ASP .Net 0 07-27-2003 12:37 AM
Rename a web form, error - missing some other reference? Kathy Burke ASP .Net 1 07-26-2003 04:02 PM



Advertisments