for %%f in (*.txt) do (
set filedatetime=%%~tf
set filedate=!filedatetime:~0,11!
if %datestamp%==!filedate! echo true >>C:\pathway\temp_log.txt
)
The above code is meant to take the Date Modified of every text file in the folder, shorten it to just the date (including the space), and compare it to a predetermined variable, datestamp.
According to the command prompt, filedatetime is getting set to the Date Modified of the file and datestamp holds the value that it should, but the code does not run correctly. Adding echo !filedatetime! and echo !filedate! only returns the literal strings !filedatetime! and !filedate!, not the values that those variables represent.
Looking up similar posts, the answer seems to be delayed expansion, but I'm pretty sure that's what I'm already doing.