I have made a batch script that tests all valid Winrar archives on a drive. It works pretty well but I have run into trouble when the file or folder name contains an exclamation mark (!).
This is where I am thus far ("ECHO !test!" is for testing purposes):
@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^" ^|