get file name in batch file

Can I get file name in batch file:
1. Input a text string
2. find the file including input string in current dir
3. display the file name
YuanyuAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sirbountyConnect With a Mentor Commented:
Not sure I completely understand, but depending on your OS - you can try:

@echo off
set /p filename=Which file would you like to search for?
dir .\%filename%
echo %filename%
0
 
YuanyuAuthor Commented:
The string I inputed is only part of filename, for example, when I input '12', I like to get '*12*.*'
0
 
sirbountyCommented:
I didn't understand that from your original question - why did you accept this one if it wasn't a complete answer?
I shoot for an "A" grade, so...
Change the "dir" line to

dir .\*%filename%*

and that should do it for you! : )
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.