Link to home
Start Free TrialLog in
Avatar of pl ll
pl ll

asked on

Last modified file name from a folder

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% .
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill Prew
Bill Prew

And this may go without saying, but just in case, you have to also replace "Username" in the path with the name of the user that you want to search the Downloads folder of.  Sorry if I'm stating the obvious, just wanted to double check...

C:\Users\Username\Downloads\*.xlsx


»bp
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial