rename

Discussion in 'Perl Misc' started by luc, Apr 4, 2004.

  1. luc

    luc Guest

    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?
     
    luc, Apr 4, 2004
    #1
    1. Advertising

  2. luc

    Xaonon Guest

    Ned i bach <gi_bc.60595$-ops.be>, luc
    <> 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." -- , in alt.atheism
     
    Xaonon, Apr 4, 2004
    #2
    1. Advertising

  3. luc

    Bob Walton Guest

    Xaonon wrote:

    > Ned i bach <gi_bc.60595$-ops.be>, luc
    > <> 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
     
    Bob Walton, Apr 5, 2004
    #3
  4. luc

    Xaonon Guest

    Ned i bach <>, Bob Walton
    <> teithant i thiw hin:

    > Xaonon wrote:
    >
    > > Ned i bach <gi_bc.60595$-ops.be>, luc
    > > <> 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, Apr 5, 2004
    #4
  5. luc

    Xaonon Guest

    Ned i bach <>, Bob Walton
    <> teithant i thiw hin:

    > Xaonon wrote:
    >
    > > Ned i bach <gi_bc.60595$-ops.be>, luc
    > > <> 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.
     
    Xaonon, Apr 5, 2004
    #5
  6. Xaonon <> 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;
     
    Peter J. Acklam, Apr 5, 2004
    #6
  7. luc

    Xaonon Guest

    Ned i bach <>, Peter J. Acklam <>
    teithant i thiw hin:

    > Xaonon <> 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
     
    Xaonon, Apr 5, 2004
    #7
  8. Xaonon <> wrote:

    > Peter J. Acklam <>:
    >
    > > Xaonon <> 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;
     
    Peter J. Acklam, Apr 6, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugz
    Replies:
    3
    Views:
    600
    Harmit Jhajj
    Feb 25, 2004
  2. Kathy Burke
    Replies:
    1
    Views:
    455
    Ron Vecchi
    Jul 26, 2003
  3. Kathy Burke
    Replies:
    0
    Views:
    429
    Kathy Burke
    Jul 27, 2003
  4. Marina
    Replies:
    3
    Views:
    2,425
    Himanshu Dhami
    Aug 15, 2003
  5. THY
    Replies:
    1
    Views:
    381
Loading...

Share This Page