I want the name of last modified file from the folder download. I tried with the example given but not quite getting the correct result.
FOR /F "DELIMS=" %%F IN ('DIR /B /A-D /OD /TW C:\Users\Username\Downloads-??.xlxs') DO (SET FILE=%%F)
ECHO Most recently modified file is:
ECHO %FILE% > C:\Users\Username\Desktop\Results.txt
The output I am getting in Results.txt is %FILE% .