
REM Test4.bat - tell me what rar and zip files are in the current directory. My For loop at first should print out the filenames that I want to work on, as I’m going for rar and zip, we have: I’ve only made a few necessary batch files before, and not needed many loops. This means no accidental deletes will happen. Works perfectly – I want to make sure it is some folder with a post or prefix, since other folders might have already been extracted (I tend to leave them around sometimes). "C:\Program Files\7-Zip\7z" x ASTROFC.zip -o"ASTROFC.zip contents" REM Test3.bat - testing extracting one file I need a specific file, so I test this line too: Worked fine on my sample of zip files, for instance, my ASTROFC.zip file with one ASTROFC.exe file in it got extracted to the subdirectory ASTROFC (ending up with the file ASTROFC\ASTROFC.exe available). This is what I want to avoid 🙂įor extracting files, there was a good example in the actual 7zip help file: I wanted to check what it compressed – in this case, it created a 7zip file with the testarchive folder in addition to it’s contents. It did what it says on the tin – my sample folder was compressed. "C:\Program Files\7-Zip\7z" a -t7z testarchive.7z testarchive\ REM Test1.bat Batch file to run 7zip on a folder to 7zip it

Relearning the batch scripts, here we go 🙂 First, I got this up and running: bat files to do this (it’ll also pause at the end of execution just in case you want to re-read anything). Run the files from the directory you want the script to work on, in Windows XP you can just double click on the. They don’t contain confirmations or much in the way of error checking besides what I describe below, so be careful if you do use them. Yes, batch files are old 😀 but I don’t have another working scripting language handily installed.


You’ll need the 7zip program to do this, and most of the examples here should be easily modifiable to suit needs.

This is was to more tightly compact lots of random zip files I have in various places, and to stop Windows not helpfully searching them slowly whenever I did a search (I bet I can disable it, but it is useful for some vary limited amount of zip files). So, I forayed into creating a batch file to recompress lots of zip or rar files into the slightly higher compressed 7zip format.
