Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Renaming Multiple Files with Different Names

by NetWallah (Abbot)
on Nov 02, 2011 at 02:30 UTC ( #935269=note: print w/replies, xml ) Need Help??

in reply to Renaming Multiple Files with Different Names

Monks here can help you, if your are clearer on what you are trying to do.
We need more specifics - from the program you posted, we see it generates file names like "nnn.tabular".
What are you trying to change the name to ?

What did you change "%03d" to ?
What does your "specification" file look like ?
Show us the code you used to change a single file name.

            "XML is like violence: if it doesn't solve your problem, use more."

  • Comment on Re: Renaming Multiple Files with Different Names

Replies are listed 'Best First'.
Re^2: Renaming Multiple Files with Different Names
by Feral_Akodon (Initiate) on Nov 02, 2011 at 15:41 UTC

    I would like to change the file names to the value of column one from the original file.

    So I've tried changing %03d to $ID and to $_ (I had no reason to choose this, but just wanted to see if it failed).

    For the single file name, I'm just doing it in command line so as an example

    rename 001.tabular 3972

    I'm not sure what file you mean as the spec file.

      I do have a text file that matches the name of the current file (i.e. old file name) and the new file name. It's in tabular format.

      I feel like it should be a rename code with $ARGV[0] as $old and $ARGV1 as $new. But when I do that it just tries to rename the text file containing the corresponding names.

      Also I'm using Strawberry Perl on a PC, so sometimes it doesn't like command line prompts.

        Something like this?
        perl -nae 'rename $F[0], $F[1]' newnames.lst

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935269]
[Corion]: Meh. I get the feeling I should post a call-to-action for people to test their modules with the upcoming 5.26 (or 5.25.latest), as it seems that the smoke testers don't really weed out modules that fail without . in @INC
[Corion]: But without instructions on how to easily test things yourself, I don't think such a call to arms is helpful
[Corion]: (this post on / p5p makes it seem to me that smoke testers seem to have a blind spot there)
[Corion]: Hmmm. Maybe setting $ENV{PERL5LIB}=" some path without dot"; perl Makefile.PL; make test already is enough to locally test your module...
[Corion]: Meh, no, will need a BEGIN hook...
[Corion]: ... and PERL5OPT does not like -e in it :-(
[Corion]: Ah. The magic invocation is set PERL5OPT=-M-lib=. (equivalent of no lib '.';
[Corion]: )

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-03-27 08:06 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (317 votes). Check out past polls.