我制作了一個批處理腳本來測驗驅動器上所有有效的 Winrar 檔案。它作業得很好,但是當檔案或檔案夾名稱包含感嘆號(!)時我遇到了麻煩。
這是我到目前為止的位置(“ECHO!test!”用于測驗目的):
@ECHO OFF
SETLOCAL EnableDelayedExpansion
FOR /F "tokens=1,2* skip=2" %%a IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe" /V "Path" 2^>nul') DO SET sti=%%c
IF EXIST "%sti%\WinRAR.EXE" (
SET PATH="!sti!";!PATH!
SET count=0
SET countall=0
SET countpct=0
IF EXIST archive_errors.log MOVE archive_errors.log archive_errors.log.bck
FOR /R %%z IN (*.rar *.zip *.arj *.lzh *.ace *.7z *.gz *.uue *.bz2 *.jar *.xz *.z) DO SET /A countall =1 >nul 2>&1
FOR /R %%z IN (*.rar *.zip *.arj *.lzh *.ace *.7z *.gz *.uue *.bz2 *.jar *.xz *.z) DO (
SET /A count =1
SET /A countpct="(!count!*100)/!countall!"
<NUL SET /P= %%z ^(!count! / !countall! - !countpct!%%^)
SET test=!%%z^:^!=!
ECHO !test!
WinRAR t !test!
IF ERRORLEVEL 1 (
ECHO ERROR^!
ECHO Errors detected in ^"%%z^" ^|
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/520262.html
標籤:细绳批处理文件代替
上一篇:如何用R中的采樣字符替換通配符
下一篇:如何在字串中添加值
