Solved

get file name in batch file

Posted on 2004-09-23
3
1,068 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:Yuanyu
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 50 total points
ID: 12139910
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
 

Author Comment

by:Yuanyu
ID: 12139991
The string I inputed is only part of filename, for example, when I input '12', I like to get '*12*.*'
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 12142097
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question