0

I have 3 Perl scripts and i run them through batch file

Script.bat

perl script1.pl %1
perl script2.pl %1
perl script3.pl %1

I run it from cmd, by just running the script.bat and file name(.C files)

script.bat <file_name>

How do i make it run for all the files in a specific folder

for example

FOLDER ABCD has files a.c, b.c and d.c

then after typing the command

script.bat ABCD

all the three files i.e a.c, b.c and d.c should get executed

1
  • The proper way would be to alter your script to accept a list of files instead of just one file. E.g. put a loop around it such as for my $file (@ARGV) and then call it with perl script.pl ABCD/*. Although if you are in Windows, the shell will not glob for you, so you need to do that yourself with @ARGV = map glob, @ARGV. Commented Nov 20, 2013 at 13:53

1 Answer 1

1
perl -le "-f and print and `script.bat $_` for map <$_/*>, pop||'.'" ABCD

it defaults to current dir when no folder name given.

Sign up to request clarification or add additional context in comments.

4 Comments

ok.. but this command has to be run through command line.but i need a perl script so that anyone else(who doesn't even know perl) can run it
@Ad-vic you can put it in another .bat file? :)
excuting the batch file containing the above code just prints it, doesn't execute
@Ad-vic I've added output for files which are passed to script.bat so it can be easier to debug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.