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% .
Microsoft DOS

Avatar of undefined
Last Comment
Bill Prew
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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
Avatar of Bill Prew
Bill Prew

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Microsoft DOS
Microsoft DOS

Microsoft Disk Operating System (MS-DOS) was an operating system for x86-based personal computers, and traces of it are still found in the Windows operating system. DOS is still used in some embedded systems and for certain legacy 16-bit networks.

14K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo