http://www.perlmonks.org?node_id=935429


in reply to Re: Renaming Multiple Files with Different Names
in thread Renaming Multiple Files with Different Names

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.

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

    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