Você simplesmente precisa usar apenas um loop omitindo o parâmetro /d
e ele funcionará exatamente como descreve criar o (s) arquivo (s) de arquivo zip e não conter sua pasta pai.
Commands
Note: This will add a zip archive file for each file in the directory with only that file in the zip.
for %%X in (*) do "C:\Program Files-Zipz.exe" a "%%~X.zip" "%%~X"
Note: This will add all files only in the directory to the one zip file you specify.
for %%X in (*) do "C:\Program Files-Zipz.exe" a "<MyZipFileName>.zip" "%%~X"
Nest Loop Command
Note: This will add files only from the directories beneath the directory which the batch file resides to a zip file matching the name of the directory.
@ECHO ON FOR /F "TOKENS=*" %%A in ('DIR /S /B /AD "*"') DO ( FOR %%B IN (*) DO ( "C:\Program Files-Zipz.exe" a "%%~fA.zip" "%%~fA\*") ) EXIT
Mais recursos
- Para / F
-
FOR /?
tokens=x,y,m-n - specifies which tokens from each line are to be passed to the for body for each iteration. This will cause additional variable names to be allocated. The m-n form is a range, specifying the mth through the nth tokens. If the last character in the tokens= string is an asterisk, then an additional variable is allocated and receives the remaining text on the line after the last token parsed.
- Dir
- Para
- um comando (Adicionar)