Wednesday, September 25, 2013

Line count with .bat

When it comes to routine, some can think of wasted hours, yearning, many cups of cofee trying to to fall asleep during your work. In that case it's better to think about robots. Let robots do their staff.

I have a perl script which has to be called 100 times for each of VS solution subdirectory. I don't want to write another Perl script to automate it, so let's use .BAT file:
@echo off

if "%1" == "" GOTO HELP

for /D %%D in (%1*) do perl the_script.pl %%D > %%D.txt

goto END

:HELP
echo test_resource_funs_loop.bat - calls test_resource_funs.pl with each subdirectory
echo Usage example: test_resource_funs_loop.bat C:\Dev-9.1\hyp_src\

:END
Thanks to Brett Batie I've written Linux wc command analogue to count # of lines in the archived 100 .txt files:
@echo off
findstr /R /N "^" %1  |find /C ":"

No comments:

Post a Comment