You can start with a batch scrpit like this:
@echo off
setlocal EnableDelayedExpansion
for %%a in (*.rar) do (
UnRAR.exe l "%%a" | findstr /C:".D....." >nul
if !errorlevel!==0 (
echo File %%a contains dirs
UnRAR.exe x "%%a"
)
if !errorlevel!==1 (
echo File %%a does not contain dirs, extracting in %%~na
mkdir "%%~na"
UnRAR.exe x "%%a" "%%~na\"
)
)
This will execute UnRAR.exe l filename
for every *.rar
file in current dir, it then checks if it contains the string .D.....
, and it extract the rar in the current dir if the string is not found, otherwise it will create a directory with the same filename as the archive (but without the extension) and extracts the archive there. Please check if the syntax of UnRAR.exe that i've used is correct.
EDIT: this codes loops recursively through subdirectories:
@echo off
setlocal EnableDelayedExpansion
for /r "%1" %%a in (*.rar) do (
UnRAR.exe l "%%a" | findstr /C:".D....." >nul
if !errorlevel!==0 (
echo File %%a contains dirs, extracting in "%%~dpa"
UnRAR.exe x "%%a" "%%~dpa"
)
if !errorlevel!==1 (
echo File %%a does not contain dirs, extracting in %%~dpna
mkdir "%%~na"
UnRAR.exe x "%%a" "%%~dpna\"
)
)