I would to have PowerShell zip the contents of a bunch of folders and get an individual ZIP file for each folder. Recently, I asked how to do this with a .bat file and an answer was provided.
for /D %%d in (*.*) do "C:\Program Files\7-Zip\7z\7za.exe" a -tzip %%d.zip %%d
However, this proved useful only for folders that have no spaces in their name. The reason being that batch will do the following: if the folder name is "Jeff's vacation pictures", the variables will be:
%%d = Jeff's<br>
%%e = vacation<br>
%%f = pictures<br>
And then it tries to pass only %%d
to the 7-Zip program, which will not find such a folder and therefore will not create a ZIP file.
I've tried looking up some tutorials, documentation sites and such, but I haven't been able to come up with an answer. There may be an answer, but I want to take this opportunity to try my hand at PowerShell.
I was thinking that a function with one argument, that being the parent-folder of the sub-folders that need to be zipped, would be the best approach.
So here's what I have, which doesn't work, probably due to my general inexperience with PowerShell:
function zipFolders($parent) {
$zip = "C:\Program Files\7-Zip\7z\7za.exe";
$parents | ForEach-Object $zip a -tzip
}