- how to return a path/filename from a wildcard filename
- Posted by Mitch Mooney on January 18th, 2004
I need to get the path or the actuall filename from a wildcard filname.
example: If EXIST c:\app* would return true based if it could find a
wildcard filename matching that entry. So if appfoo returned true to c:\app*
how do I get that filename to a varible?
- Posted by foxidrive on January 19th, 2004
On Sun, 18 Jan 2004 20:39:46 GMT, Mitch Mooney wrote:
This will return the last match.
@echo off
for %%a in (c:\app*.exe) do if exist %%a set var=%%a
- Posted by Dr John Stockton on January 19th, 2004
JRS: In article <maCOb.5523$MV4.1840@nwrddc03.gnilink.net>, seen in
news:alt.msdos.batch, Mitch Mooney <mr.mhmooneyidontwantspam@verizon.net
One should consider the possibility of there being more than one match.
dir c:\app* /b LFN, sub-dirs
HUNT c:\app s o SFN, sub-dirs, can super-dirs, drives
dir has /o:?
HUNT can select by other criteria, or search just the Path.
Pipe through OVER to reverse order
Pipe through COLS &N-1 1- . to select only the N'th entry
Pipe into STOW thatzit to store first line in variable THATZIT.
HUNT, OVER. COLS, STOW via sig line 3 below.
HUNT sets ERRORLEVEL, so success can be checked.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; Win98. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
- Posted by Ted Davis on January 19th, 2004
On Mon, 19 Jan 2004 06:03:08 GMT, foxidrive <foxidrive@Shotmail.com>
wrote:
Since FOR will only return files that exist, is the IF EXIST test
really necessary?
T.E.D. (tdavis@gearbox.maem.umr.edu - e-mail must contain "T.E.D." or my .sig in the body)
- Posted by foxidrive on January 20th, 2004
On Mon, 19 Jan 2004 12:30:00 -0600, Ted Davis wrote:
Well spotted, Watson.
- Posted by Mitch Mooney on January 20th, 2004
Thanks to all responces.
"Dr John Stockton" <spam@merlyn.demon.co.uk> wrote in message
news
XXGp7I9X8CAFwON@merlyn.demon.co.uk...