?
Solved

get file name in batch file

Posted on 2004-09-23
3
Medium Priority
?
1,096 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 150 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

741 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