Hello all,

I am trying to create a batch file to recurse through a tree and create par2 files for each subdir. -- http://www.par2.net/

I'd like a script to run in c:\dir that will run through c:\dir\1\ , c:\dir\2\ , c:\dir\3\ , and subdirs c:\dir\1\a\ etc.

par2 runs on a file if given a filename, or all files within the current directory if not given one.

So the batch should run in each subdir without being passed a filename, so it creates par2 files for the whole subdir rather than each file in turn.

I guess a "for x in y do z" should manage it but not sure.

Thanks for your help,
Ben

Ah, forgot all about this!

Having learned more about batch files, the following does what I was after:

setlocal
FOR /d %%f in (%1) do SET fulltarget=%%~ff
FOR /f "delims=" %%f in ('dir %1 /ad /b') do (call :main "%%f")
GOTO end

:main
setlocal
set foldername=%~nx1

pushd "%fulltarget%\%1"
par2 c "%foldername%.par2" *.*
popd
GOTO:EOF

:end
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.