I am trying to get the lastmodified date of files which have almost the samename (CompactReg00 in common).
I want this date to be safe to different date settings so I was thinking to use wmic command. The command work well if I use it like that :
set filename=CompactReg00_20200504T112430Z
for /f %%p in ('wmic DataFile where "name='C:\\Temp\\Alarm\\Archive\\20200508\\sDiag\\%filename%'" get lastmodified ^| find "+" ') do set "val=%%p"
echo %val%
but when I want to include it to another for loop to get lastmodied date of all "CompactReg00" files I cannot get the %val% value
here is my script:
for /R %%a IN (*CompactReg00*) DO (
echo %%~na
for /f %%p in ('wmic DataFile where "name='C:\\Temp\\Alarm\\Archive\\20200508\\sDiag\\%%~na'" get lastmodified ^| find "+" ') do set "val=%%p"
echo %val%
echo %%~na_%val%
)
Can you help me to correct it or find another way to get this lastmodified date always yyyymmdd