0

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

1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by benpollinger
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.