1
votes

Using 7zip, I want to give a location of a folder of files something like... D:\Home\files Then I want it to zip all the files in that folder and leave them there. So for example zipme.txt become zipme.zip, so all files would keep their name but just become a zip file. I have tried to use

FOR %i IN (D:\Home\files) DO 7z.exe a "%~ni.zip"

But when I do it it adds a zip file for the directory so my output would be in the correct folder but would contain

D:\Home\files\file.zip
D:\Home\files\zipme.zip
   zipped files also all items in directory like..
   zipme.txt
   zipme2.txt
D:\Home\files/zipme2.zip

So how can I zip each file individual in a folder and have the new zipped name be the individual files name

1

1 Answers

0
votes

Was able to get this to work.

FOR %i IN (D:\Home\files\*) DO 7z.exe a "%~ni.zip" "%i"