Calling all .BAT file magicians

Started by Tynan, October 11, 2013, 02:23:51 PM

Previous topic - Next topic

Tynan

I've struggled with this a bit; figured one of you geniuses might be able to help out!

The task: Create a .bat file (or equivalent) that individually zips up every subfolder in a folder.

This is for automated building of the game. I've already got a script that builds all six (3 OS's times the dev/nondev versions) versions of the game and puts them in a folder. It ends up looking like this:

..../RimWorldBuilds/RimWinDev226/
..../RimWorldBuilds/RimMacDev226/
..../RimWorldBuilds/RimWin226/
and so on

Basically I would like it to end up by adding these files as well:

..../RimWorldBuilds/RimWinDev226.zip
..../RimWorldBuilds/RimMacDev226.zip
..../RimWorldBuilds/RimWin226.zip

Which just means individually zipping each folder in the containing RimWorldBuilds folder.

So - does anyone know how you'd write a script that could do that? Thank you!
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Haplo

I had the same problematic on work today, but unfortunately it was too late to spend much time searching for that.
(Strange coincidence that :) )

Most likely I'll use the 7za.exe from 7-zip (I think this should work for your purpose):
7z.exe a -tzip ".../RimWorldBuilds/RimWinDev226.zip" ".../RimWorldBuilds/RimWinDev226/"
7z.exe a -tzip ".../RimWorldBuilds/RimMacDev226.zip" ".../RimWorldBuilds/RimMacDev226/"
7z.exe a -tzip ".../RimWorldBuilds/RimWin226.zip" ".../RimWorldBuilds/RimWin226/"

For more, take a look here: http://www.dotnetperls.com/7-zip-examples

Tynan

Ah ha, a good start, but I'd need something that zips every folder in the folder, regardless of name. I can't put all the names in ahead of time, because they change daily with the build number. Should have made that clearer. It'll have to iterate all folders in the containing folder.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

British

@echo off

for /d %%i in (..\RimWorldBuilds\*) do (
7z a -r -tzip %%~ni.zip %%i\
)

[/size]
Adapt the path in the parenthesis, but be careful though, as the paths in the zip will take that into account.
Try and come back here if that's not good enough.

My 7zip was also not in my path, so I put 7z.exe and 7z.dll with the .bat.


Tynan

Tynan Sylvester - @TynanSylvester - Tynan's Blog