This is kind of what I was thinking too as a way to speed it up. I like the delimiters usage--very clever! I could replace the for loop with simplypenpen wrote:I don't know if the following is much faster, but you could try to avoid using environment variables (instead this uses a tempfile; not tested):The first loop may be replaced by a dir command (may be faster); in that case you probably have to adjust the tokens in the other loops.Code: Select all
@echo off
setlocal
:: ... set current date ...
>list.temp (
for %%f in ("DAY*.RPT" "PLU*.RPT" "SKU*.RPT" "*.txt") do echo(%%~tf %%~nx
)
for /F "token=2" %%f in ('findstr "^%currentdate%" "list.tmp"') do (
for /F "token=1 delims=YU" %%t in ("%%~f") do (
if "DA" == "%%~t" ( SET DAY=%%f
) else if "PL" == "%%~t" ( SET PLU=%%f
) else if "SK" == "%%~t" ( SET SKU=%%f
)
)
)
del "list.temp"
endlocal
goto :eof
penpen
Code: Select all
DIR *.RPT > list.temp
Code: Select all
DIR DAY*.RPT > list.temp
DIR SKU*.RPT >> list.temp
DIR PLU*.RPT >> list.temp
But then I started re-thinking the whole task of getting these filenames into the variables.
My data set consists of just one "DAY" file, one "SKU" file, and one "PLU" file per date. A
Code: Select all
DIR DAY*.RPT|FIND "%currentdate%"