(win) mutiple directories to zip files without path info

Discuss whatever insanity comes to mind. Please keep it friendly and clean though.

Moderator: General Mods

Post Reply
odditude
Official tech support dood
Posts: 2118
Joined: Wed Jan 25, 2006 7:57 am

(win) mutiple directories to zip files without path info

Post by odditude »

long story short, needed to rearchive a bunch of RSNs as ZIP files due to a player which handles RSNs clumsily. 7-zip will gladly dump each to its own directory via multiselect and context menu, but i didn't see a simple way to reverse the operation.

in case anyone else needs to do this, just run this from the console in the parent directory (or save it as a .bat/.cmd and drop it there for convenient reuse):

Code: Select all

for /d %%i in (*) do "c:\program files\7-zip\7z" a "%%i.zip" ".\%%i\*"
e.g. if your SPC files are in c:\spcs\(gamename)\, then drop this in c:\spcs.

i'm running win7, but i don't think the syntax for FOR has changed in NT - YMMV in DOS/9x, though.
Why yes, my shift key *IS* broken.
kode54
Zealot
Posts: 1140
Joined: Wed Jul 28, 2004 3:31 am
Contact:

Re: (win) mutiple directories to zip files without path info

Post by kode54 »

Make a batch file that will change directory into the source directory, pack up the files within into a zip file at your specified absolute path, then cd back to that directory.

To help with that, you can specify the path to the zip and the path to zip into it:

blah.bat "d:\music\spc\Secret of Mana"

Leaving off the trailing slash from the path is important.

And this batch file will work:

Code: Select all

@echo off
setlocal
for /f %%p in ('cd') do @set cwd=%%p
for /f %%p in ('cd') do @set cdd=%%~dp
%~d1
cd "%1"
7z a "%cwd%\%~n1.zip"
%cdd%
cd "%cwd%"
Post Reply