@echo off
setlocal enableextensions enabledelayedexpansion
set /p "start=Start (hh:mm): "
set /p "end=End (hh:mm): "
set "somewhere=%cd%"
for /f "tokens=1-2 delims=-" %%a in ('dir /b /on /ad "%somewhere%"') do (
if "%%b" geq "%start::=_%" if "%%b" leq "%end::=_%" (
for %%c in ( "%somewhere%\%%a-%%b\a\*.*" "%somewhere%\%%a-%%b\b\*.*") do (
for /f "tokens=*" %%d in ("%%~dpc.") do (
echo(%%a-%%b-%%~nxd%%~nxc
)
)
)
)
pause
Here is a batch file to create the test case folders and files:
@echo off
for %%a in (1 2 3 4 5) do for %%b in (A B) do for %%c in (
02_25-06_00
02_25-06_10
02_25-06_20
02_25-06_30
02_25-06_40
02_25-06_50
02_25-07_00
) do md %%c\%%b 2>nul& type nul>%%c\%%b\%%a.txt
EDITED - Include code changes to adapt to new folder naming (stated in comments). Changes included:
folder a = 9k (changes in
for %%c
files set)folder b = c2 (changes in
for %%c
files set)time named folders = hh-mm_hh-mm (changes in
for %%a
delims, hour comparision variable substitution,for %%c
files set)
The rest of the code remains without changes
for /f "tokens=1-2 delims=_" %%a in ('dir /b /on /ad "%somewhere%"') do (
if "%%b" geq "%start::=-%" if "%%b" leq "%end::=-%" (
for %%c in ( "%somewhere%\%%a_%%b\9k\*.*" "%somewhere%\%%a_%%b\c2\*.*") do (
for /f "tokens=*" %%d in ("%%~dpc.") do (
echo(%%a-%%b-%%~nxd%%~nxc
)
)
)
)