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
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)
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.
Summary: We are switching over from our Unix version of software to a windows version. I only know korn shell scripting, and now need to learn VBScript. Can someone help me get started with rewriting a shell...
Summary: I need help with one of my homework review problems. If a child bought 147 cans of beans for his family, and could only carry 45 cans at a time, how many trips home must he take? Please help. I'ts due...
Summary: My program will not output the second part : where it has to add the even numbers and show the sum. I did not code the third part with letters yet... Please help with this... //***********************...