Hey all. I'm trying to make a perl script create some bat scripts to run
some specific command and run a few at a time. If that makes any sense.
Anyhow, say there are 20 files in a dir. Now these files change at times,
so to make it easier I'm making a perl script to make the bat scripts to
run these specific commands on each file, reason is, so I can run a few at
a time to save time. Now there are man more than this, but I'm making it
simple just so I can expand on this later. Here is my convoluted script
right now, I'm just using jpg's just as an example, but here it is:
The first result of 10 commands on 10 files works fine, but the second one
is empty. Any pointers in the right direction? Thanks.:
-------------
use File::Find;
my @all_file_names;
my $x = 0;
my $file1 = 'C:/Users/MeHere/test1/thefile1.txt';
find sub {
return if -d;
push @all_file_names, $File::Find::name;
}, 'C:/Users/MeHere/Downloads/Pics/Temp';
open FILE, ">$file1" or die $!;
for my $path ( @all_file_names ) {
while ($x < 10) {
$x = $x+1;
print FILE "echo PART 1a\n" if $x == 1;
print FILE "pause\n" if $x == 1;
#$path = (s/\//\\/g); (also trying to replace / with \ for windows)
print FILE "do this command $path -d -S 10\n" if $path =~ /\.JPG/;
print FILE "Done with PART 1a\n" if $x == 10;
print FILE "pause\n" if $x == 10;
print "$x\n";
}
close FILE;
my $file2 = 'C:/Users/MeHere/test1/thefile2.txt';
open FILE, ">$file2" or die $!;
while ($x < 20) {
$x = $x+1;
print FILE "echo PART 1b\n" if $x == 11;
print FILE "pause\n" if $x == 11;
print FILE "do this command $path -d -S 10\n" if $path =~ /\.JPG/;
print FILE "Done with PART 1b\n" if $x == 20;
print FILE "pause\n" if $x == 20;
print "$x\n";
}
}
close FILE;
------------------------------
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/