×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Windows batch program - check for files

Windows batch program - check for files

Windows batch program - check for files

(OP)
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

RE: Windows batch program - check for files

Try this:

CODE

Option Explicit

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

strPath = "C:\Test\"
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.

RE: Windows batch program - check for files

Change

CODE -->

If LCase(strFile) = "file" & i & "_yyyymmdd.csv" Then 
to

CODE -->

If LCase(strFile) Like "file?_" & format(date,"yyyymmdd") & ".csv" 

RE: Windows batch program - check for files

(OP)
Thanks a lot

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

RE: Windows batch program - check for files

forum329: VBScript

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Windows batch program - check for files

>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: Microsoft: Windows

RE: Windows batch program - check for files

(OP)
Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close