Zip and Delete Directory in Loop using Batch Comma

2019-08-11 11:24发布

I have a batch command. As it follows. It can zip directories in other directory.

@echo off
    set "zip=7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on"
    set "directory=C:\SqlData\BackUpData"
    for /d %%i in ("%directory%\*") do %zip% "%%~fi.7z" "%%~fi\*"

I want to add one more line. It should delete original file after zipped. Thanks.

1条回答
Lonely孤独者°
2楼-- · 2019-08-11 11:55

If I understand you correctly, I think this is the line you're looking for:

for /d %%i in ("%directory%\*") do del "%%~fi\*.*" /q
查看更多
登录 后发表回答