我一直在使用这个脚本来提取和删除档案,但是由于某些原因,它没有正确地处理名为.part##.rar的档案。我做错了什么?
for /r %%r in (*.zip *.7z *.rar *.ace) do 7z x -y "%%r" >nul && del "%%r" && echo unpacked "%%~nxr"编辑:我决定将其构建到一个单独的脚本中,该脚本处理单个文件夹%1中的所有档案。
:security
cd /d "%~1" || echo no valid directory defined && exit /b
attrib -s -h *.* >nul
dir *.rar *.zip *.7z *.ace >nul 2>nul || exit /b
:extract
for %%r in (*.zip.001 *.7z.001 *.tar.001) do (
7z x -y "%%r" >nul && recycle -f "%%r" && echo unpacked "%%~nxr"
if exist "%%r" echo unpack failed, maybe the disk is full? && exit /b
recycle -f "%%~dpn.???" && echo multipart archives "%%~dpn.???" recycled
)
for %%r in (*.part1.rar *.part01.rar *.part001.rar) do (
7z x -y "%%r" >nul && recycle -f "%%r" && echo unpacked "%%~nxr"
if exist "%%r" echo unpack failed, maybe the disk is full? && exit /b
rem need a way to delete multipart volumes here
)
for %%r in (*.rar *.zip *.7z *.ace *.tar) do (
7z x -y "%%r" >nul && recycle -f "%%r" && echo unpacked "%%~nxr"
if exist "%%r" echo unpack failed, maybe the disk is full? && exit /b
if /i "%%~xr"==".rar" if exist "%%~dpnr.r00" recycle -f "%%~dpnr.r??" && echo multipart archives "%%~dpn.r??" recycled
)
goto security我需要帮助删除中间堆栈中的剩余文件。
发布于 2017-11-23 12:15:05
这将尝试使用正则表达式尽可能将异常缩小到所使用的模式:
for /F %%f in ('dir /b /a-d *.zip *.7z *.rar *.ace ^|findstr /REIV /C:"\.part[0-9][0-9]*\.rar"') do @(7z x -y "%%f" >nul && del "%%f" && echo unpacked "%%~nxf")https://stackoverflow.com/questions/47451815
复制相似问题