troubleshooting Question

Last modified file name from a folder

Avatar of pl ll
pl ll asked on
Microsoft DOS
3 Comments2 Solutions145 ViewsLast Modified:
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.
@ECHO OFF
 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%
 ECHO %FILE% > C:\Users\Username\Desktop\Results.txt

The output I am getting in Results.txt is %FILE% .
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros