I have a folder that, besides other things, has folders named after dates, e.g. 20110908 20110909 and so forth. Every night, I would like to run a tool that checks for all folders matching that datemask (could be 201*), and bzip2 any of them that don't already have a similarly named bzip2 archive. And ideally, if after bzip2-ing the folder contents change, I would like to re-bzip2 them.

Is there a tool out there that would help me?

link|improve this question

75% accept rate
feedback

1 Answer

up vote 1 down vote accepted

The command line version of 7-Zip can help you here. You can create a batch file that you schedule using Task Scheduler. You would want to use 7-Zip's update switch "u". A script something like the following might do the trick:

for /f %%F IN ('dir /b 201*') (

    REM Extract
    7z e %F.tar.bz2 %F.tar

    REM Update archive
    7z u %F.tar -uq2r2y2z2w2 %F

    REM Compress
    7z a %F.tar.bz2 %F.tar

    REM Delete tar
    del %F.tar

)

If you can get away with using zip or 7z format, then you can skip the "extract, then recompress" steps and simply run the update step.

link|improve this answer
Perfect, thanks! – Cookie Sep 11 '11 at 20:55
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.