1

I have 4 Perl scripts and i run them through batch file to run on each file

Scripts.bat

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

Then to run it in a given folder i use the perl command(here %1 is where folder name is passed)

perl -le "-f and print and `scripts.bat $_` for map <$_\\*>, pop||'.'" %1

But this works on only folder in 1st level .

I need to make it run through folder recursive(folder within folder). It can have more than 2 levels of folder within folder also.

Like if

abc(folder) > xyz(folder) > file4.c, file5.c, file6.c
            > file1.c
            > file2.c
            > file3.c

It should run on all files.

Any kind of help is welcome, be it some perl script or one liner perl command or batch file

1
  • See File::Find. Commented Dec 16, 2013 at 14:11

1 Answer 1

1

From batch file:

for /r "c:\abc" %%f in (*.c) do call "scripts.bat" "%%f"

To run it from command line, replace %%f with %f

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

3 Comments

@Ad-vic: Just an example, as it seems bad asummed from your samples. What it does is enumerate all the *.c files under c:\abc and calls "scripts.bat" with the full name of file (with path) as parameter. Replace "c:\abc" with the root directory from where to start to search files, or if it is the same directory as the commandline/batch file replace with ".".
thanks !! works fine. I used "%1" instead of "C:\abc" so that i could pass folder name through argument
you made it look so simple.just a 'for' '/r for recursive' and 'call'.

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.