I solved this problem, see answer below. Now my question is, how to make it tolerate directories with spaces in the dir name.
I'm looking for a command line for 7zip that achieves the following: I have a base folder, containing many subfolders, each of which contains many zip files. Each zip file in turn contains many files. Like this:
c:\base\dir1 \dir1\x1.zip \x1.zip\file1.txt \z1.zip\file2.txt \dir1\x2.zip \x2.zip\file1.txt \x2.zip\file1.txt
\dir2\z1.zip \z1.zip\file1.txt \z1.zip\file2.txt \dir2\z2.zip \z2.zip\file1.txt \z2.zip\file2.txt
[the same structure repeated for dir3, dir4...dirn]
What I'm trying to achieve is this.
c:\base\dir1 \dir1\x1 \x1\file1.txt \x1\file1.txt \dir1\x2 \x2\file1.txt \x2\file1.txt c:\base\dir2\ \dir2\z1 \z1\file1.txt \z1\file2.txt \dir2\z2 \z2\file1.txt \z2\file2.txt
In other words, each of the zip files have been unzipped into subfolders with the same name as the zip file. Those subfolders are in the same folder that each zip file was in.
I have tried this:
for /F "usebackq" %f in (
dir /b/a:d) do C:\APPS\7-Zip\7z.exe x .%f*.zip -o%f
But this places all the unzipped files in the folder the zip is in (x1.zip gets unzipped to c:\base\dir1, z1.zip gets unzipped to c:\base\dir2, etc.) rather than into subfolders No subfolders named after the zip file are created. IOW this:
c:\base\dir1 \dir1\file1.txt \dir1\file2.txt
etc. I also tried this:
for /F "usebackq" %f in (`dir /b/a:d`) do "C:\Program Files\7-Zip\7z.exe" x .\%f\*.zip -o*
Now subfolders named after the name of the zip file are indeed created, but all of them are in c:\base, like this:
c:\base \base\x1\file1.txt \base\x2\file2.txt
Again, what I'm going for is:
c:\base \base\dir1\x1\file1.txt \base\dir2\z1\file1.txt
Sorry for this very longwinded post about what seems to be a fairly simple operation. I really struggled getting the formatting of my sample folder trees to look right, so apologies if they're confusing. If anyone knows how to do this, hopefully with the right command line, I'll be grateful.