Computing.Net > Forums > Programming > VBScript help with ? wildcard

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBScript help with ? wildcard

Reply to Message Icon

Name: humerick
Date: June 19, 2006 at 10:33:24 Pacific
OS: WinXP
CPU/Ram: Intel
Product: Dell
Comment:

I need some help finding out a way to see if any files exist in a particular directory that are like NWA?1QRT.DAT. I can't get my VBscript to work with the ? wildcard. If any files exist that meet the search, then I need that exact name of the file.

The following code does not work:

Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists("Rpt_File_Name") Then
Wscript.Echo "rpt file exists"
else
Wscript.Echo "rpt file does not exist"


The Rpt_File_Name is the variable used to hold the file name that I am looking for (ie. NWA?1QRT.DAT)

Thank you,
Scott



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: June 19, 2006 at 13:14:25 Pacific
Reply:

I don't believe you can use a wildcard in the FileExists command.

Assuming that you are searching in a particular directory, I think the only way you will be able to accomplish this is by looping through all of the files in that directory and testing the name against the Rpt_File_Name.

Probably the best way to do that would be through the use of regular expressions. You would need to craft the regular expression to handle the '?' as any character. I'm by no means an expert in that area though. Here's a tutorial that might help you get started.

http://www.windowsitpro.com/articles/print.cfm?articleid=9170

Michael J


0

Response Number 2
Name: humerick
Date: June 21, 2006 at 13:51:38 Pacific
Reply:

Thanks Michael. The article really helped.

Scott


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


printing bigger Logging IE URLs in real t...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBScript help with ? wildcard

VBScript help parsing a text file www.computing.net/answers/programming/vbscript-help-parsing-a-text-file/14327.html

Help with problem in C www.computing.net/answers/programming/help-with-problem-in-c/5108.html

Help with debugging C++ code www.computing.net/answers/programming/help-with-debugging-c-code/13083.html