Batch file script to zip files
for /d %%a in (*) do (ECHO zip -r -p "%%~na.zip" ".\%%a\*")
should work from within a batch.
Note that I've included an ECHO
to simply SHOW the command that is proposed. You'd need to remove the ECHO
keywor to EXECUTE the commands.
No external dependency on 7zip or ZIP - create a vbs script and execute:
@ECHO Zipping
mkdir %TEMPDIR%
xcopy /y /s %FILETOZIP% %TEMPDIR%
echo Set objArgs = WScript.Arguments > _zipIt.vbs
echo InputFolder = objArgs(0) >> _zipIt.vbs
echo ZipFile = objArgs(1) >> _zipIt.vbs
echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) >> _zipIt.vbs
echo Set objShell = CreateObject("Shell.Application") >> _zipIt.vbs
echo Set source = objShell.NameSpace(InputFolder).Items >> _zipIt.vbs
echo objShell.NameSpace(ZipFile).CopyHere(source) >> _zipIt.vbs
@ECHO *******************************************
@ECHO Zipping, please wait..
echo wScript.Sleep 12000 >> _zipIt.vbs
CScript _zipIt.vbs %TEMPDIR% %OUTPUTZIP%
del _zipIt.vbs
rmdir /s /q %TEMPDIR%
@ECHO *******************************************
@ECHO ZIP Completed
I know its too late but if you still wanna try
for /d %%X in (*) do (for /d %%a in (%%X) do ( "C:\Program Files\7-Zip\7z.exe" a -tzip "%%X.zip" ".\%%a\" ))
here * is the current folder. for more options try this link