Reputation: 79
I've been working on a batch script to check filedates. I had it working yesterday morning, but for some reason, the variables that I set have started to be non-functional. Here is the code:
for /f %%a in ('dir /B/A:D') do (
for /f "tokens=1-3 delims=/ " %%b in ("%%~ta") do (
set FCMONTH=%%b
set FCDAY=%%c
set FCYEAR=%%d
echo %FCMONTH%\%FCDAY%\%FCYEAR%
)
)
Line-by-line:
When looking at the script results in cmd.exe, FCMONTH/DAY/YEAR are all being set correctly, but the echo is failing to read them:
Does anyone have any insights to my problem? I don't understand why it's failing to work all of a sudden.
Thanks
Upvotes: 0
Views: 64
Reputation: 57252
setlocal enableDelayedExpansion
for /f %%a in ('dir /B/A:D') do (
for /f "tokens=1-3 delims=/ " %%b in ("%%~ta") do (
set FCMONTH=%%b
set FCDAY=%%c
set FCYEAR=%%d
echo !FCMONTH!\!FCDAY!\!FCYEAR!
)
)
Upvotes: 2