Egglabs
Egglabs

Reputation: 3186

Batch file to compress folder in root level.

I am trying to write a batch script that will run automatically compressing folder root level using 7zip

Folder
        a.png   
        File1.jpg
        File2.jpg
        File3.jpg
        index.html
        home.html

I tried this code, but not compressing in root level.

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a  "%%X.zip" "%%X"

Upvotes: 0

Views: 349

Answers (1)

Arun Nallamayan
Arun Nallamayan

Reputation: 361

try this

for /d %%X in (*) do (for /d %%a in (%%X) do ( "C:\Program Files\7-Zip\7z.exe" a -tzip "%%X.zip" ".\%%a*" ))

if you wanna try more options http://https403.blogspot.com/2014/09/batch-for-zip-files-and-folders-below.html

Upvotes: 1

Related Questions