仅当扩展名已知时如何删除.part1.rar,part01.rar等

时间:2018-09-10 17:19:25

标签: batch-file

这部分代码应该删除成功提取的存档,其中第一个是已知的%fullpath%\%file%.%exe%。它使用???通配符,因此它会删除.7z.001.zip.001.r01之类的多部分,但不能删除.part1.rar, .part01.rar, .part001.rar之类的多部分。

echo successfully unpacked "%fullpath%\%file%.%ext%"
attrib -r "%fullpath%\%file%.???"
for /r "%fullpath%" %%r in (%file%.???) do del "%%r" && echo deleted "%%r"

1 个答案:

答案 0 :(得分:0)

我明白了

echo unpacked "%fullpath%\%file%.%ext%"
attrib -r "%fullpath%\*.*" /s
:: maybe a little more concern here? also deletes every other filetype with the same name
for /r "%fullpath%" %%r in (%file%.??? %file:~0,-6%.part?.rar %file:~0,-7%.part??.rar %file:~0,-8%.part???.rar) do (
    if exist "%%r" del "%%r" >nul 2>nul && echo deleted extracted archive "%%r")