Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: rename files

by poj (Abbot)
on Feb 02, 2018 at 20:38 UTC ( [id://1208360]=note: print w/replies, xml ) Need Help??


in reply to Re^2: rename files
in thread rename files

Adapt as required

#!/usr/bin/perl use strict; use warnings; use Time::Piece; use File::Copy; my $path = '/Users/flieckb/Desktop/'; my $logfile = $path.'whitefiles.txt'; my $tiff = $path.'aero_tiff/'; my $whitefiles = $path.'aero_2push_white/'; my $mybadmatch = '_white.tif'; my $date = localtime->ymd; unless (-d $tiff){ die "$tiff does not exist"; } unless (-d $whitefiles){ die "$whitefiles does not exist"; } chdir( $tiff ) or die "$!"; my @tiff_list = glob "*tif"; my $upload_count = @tiff_list; open FILE, '>>', $logfile or die "Could not open $logfile : $!"; foreach my $file (@tiff_list) { if ( $file =~ /$mybadmatch/i ){ print "$file is white background match\n"; my $old = $tiff.$file; print "Copying $old to $whitefiles\n"; copy($old, $whitefiles) or warn "$!"; print FILE "$date\t$file\t\n"; } else { print "$file :normal production image\n"; } } close FILE; chdir( $whitefiles ) or die "$!"; my @white_list = glob "*tif"; foreach my $old (@white_list) { my $new = $old; if ($new =~ s/white/main/i){ print "Renaming $old to $new\n"; rename($old, $new) or warn "$!"; } }
poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1208360]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found