0

Basically what I'm trying to do is to create a program that will zip all the folders where the file is run, check the integrity of the archive, and then delete the source files. Ideally I'd like to all be done using windows/7zip command line.

This is what I have so far:

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

This zips and checks the files just fine, but it deletes all the newly created archives and their source files except for the last archive created.

Any suggestions are greatly appreciated.

Edit: This looks like a step in the right direction, but it's still not working.

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\" -mx1 -r testarchive *.zip t testarchive.zip
for /d %%i in (*) do del "%%~fi\*.*" /q
pause
Jay
  • 1
  • 3
  • take a look at this: http://stackoverflow.com/questions/35334845/zip-and-delete-directory-in-loop-using-batch-command/35373285#35373285 – Wes Larson Feb 25 '16 at 17:04
  • I tried implementing that like so, but it's still doing the same thing. See above. – Jay Feb 25 '16 at 17:26
  • If your destination zip file is in the directory as your source files, then it will be deleted with all the other files. Can you put your destination zip file in a separate folder, where it won't be caught in the `del *.*` ? – Wes Larson Feb 25 '16 at 20:53
  • 1
    You could set Del to use this command `for /f %%F in ('dir /b /a-d ^| findstr /vile ".zip"') do del "%%F"` that would delete everything apart from .zip files. Found it here [http://stackoverflow.com/questions/9424380/delete-excluding-some-extensions] – Nat Thulke Feb 25 '16 at 22:27

0 Answers0