Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows batch program - check for files

Status
Not open for further replies.

gmoorthy

Programmer
Jul 13, 2004
107
US
I need a window script which will check if I have 4 files existing in a folder with current date. The file naming convention are

File1_yyyymmdd.csv
File2_yyyymmdd.csv
file3_yyyymmdd.csv
File4_yyyymmdd.csv
 
Try this:

Code:
Option Explicit

Sub CheckFiles()
Dim strPath As String
Dim strFile As String
Dim i As Integer

strPath = [red]"C:\Test\"[/red]
strFile = Dir(strPath & "*.csv")

Do While strFile <> ""
    For i = 1 To 4
        If LCase(strFile) = "file" & i & "_yyyymmdd.csv" Then
            MsgBox "Bingo!, File is here: " & strFile
            Exit For
        End If
    Next i
    strFile = Dir
Loop
 
End Sub


---- Andy

There is a great need for a sarcasm font.
 
Change
Code:
If LCase(strFile) = "file" & i & "_yyyymmdd.csv" Then
to
Code:
If LCase(strFile) Like "file?_" & format(date,"yyyymmdd") & ".csv"
 
Thanks a lot

This is VB script , how do I do it using
Dos commands. Using find commands etc
 
Forum329

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
>This is VB script

Actually it isn't, it is VBA. Hardly surprising since this is the VBA forum. And, since you want DOS, you don't want the VBScript forum either. Try forum779
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top