Link to home
Create AccountLog in
Avatar of sdc248
sdc248Flag for United States of America

asked on

Batch file to find a file with certain name in a folder

Hi:

I need some dos command for finding a file in a folder. Here's what I have:

set OUTPATH="C:\Output"
for /f %%E in ('DIR /B %OUTPATH%\MyFile_*') do set FILENAME=%%E
echo %FILENAME%

It returns the name of the last file in the folder, plus an 'File Not Found' message.

Please help. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of sdc248

ASKER

It works. Thanks.
Avatar of Bill Prew
Bill Prew

Welcome.

~bp