in reply to renaming files from a tab delimited list

Hi flieckster,

Please show the code you've tried, and why it doesn't work. Post your code inside <code> tags, and include a sample of the data you're processing and the expected output.


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: renaming files from a tab delimited list
by flieckster (Scribe) on Mar 16, 2016 at 19:46 UTC
    i have no code to show at this point since I wasn't sure where to start. if you could point me to a module that might work i can start from there.

      For file operations: Path::Tiny

      use strict; use warnings; use feature 'say'; use Path::Tiny qw/ path /; say qx# ls /tmp/*.txt #; my $dir = '/tmp/'; my $ext = '.txt'; my $regex = qr/$ext/; my @paths = path( $dir )->children( $regex ); for my $file ( @paths ) { my $name = path( $file )->basename( $regex ); my $newname = join '', reverse split '', $name; path( $file )->move( join '', $dir, $newname, $ext ); } say qx# ls /tmp/*.txt #; __END__
      Output:
      /tmp/bar.txt /tmp/foo.txt /tmp/oof.txt /tmp/rab.txt

      Hope this helps!


      The way forward always starts with a minimal test.

      perlintro will give you all the information and example code you need to open and read the file containing your tab delimited list. Inside the loop that reads that file line by line, you could use split to split each line into its components, and then rename to rename the files. Try writing some code, posting it here (following the guidelines in How do I post a question effectively?), and I'm sure someone will be happy to help.