tgogos
tgogos

Reputation: 25152

How to compress N files to N .zip files respectively

I am looking for an easy way to deal with the following case: compress N files and generate N separate .zip files.

filename01.doc will be compressed to filename01.zip which contains filename01.doc
filename02.doc will be compressed to filename02.zip which contains filename02.doc and so on...

Upvotes: 0

Views: 142

Answers (1)

foxidrive
foxidrive

Reputation: 41234

Check the path to 7zip and remove the /s if you don't want to process subdirectories:

@echo off
for /f "delims=" %%a in ('dir *.doc /b /s /a-d ') do (  
   "c:\program files\7-zip\7z.exe" a "%%~dpna.zip" "%%a" 
)

Upvotes: 1

Related Questions