....
501-L0_04-03-2013
502-L0_04-03-2013
504-L0_04-03-2013
505-L0_04-03-2013
501-L0_06-03-2013
502-L0_06-03-2013
504-L0_06-03-2013
505-L0_06-03-2013
...
I have in a c:\dir1\ the txt files in list.
based 50X-L0_ and date is possible if the "poker" ( )of file are exactlly a block of for????
501-L0_06-03-2013
502-L0_06-03-2013
504-L0_06-03-2013
505-L0_06-03-2013
this poker of file is ok
501-L0_06-03-2013
502-L0_06-03-2013
505-L0_06-03-2013
This is a tris not a poker of file.... the file 504-L0_06-03-2013 not present in poker
check a block of files in dir
-
- Administrator
- Posts: 78628
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: check a block of files in dir
Does this do what you want? You'll have to complete the code yourself.
Code: Select all
Sub CheckBlock()
Dim strPrefix As String
Dim dtmDate As Date
Dim strDate As String
Dim strFolder As String
Dim strFile As String
Dim lngCount As Long
strFolder = "C:\Dir1\"
strPrefix = "50?-L0_"
dtmDate = Date ' or DateSerial(2013,3,4) or ...
strDate = Format(dtmDate, "dd\-mm\-yyyy")
strFile = Dir(strFolder & strPrefix & strDate & ".txt")
Do While strFile <> ""
lngCount = lngCount + 1
strFile = Dir
Loop
If lngCount = 4 Then
' We have 4 files matching the pattern
Else
' We have a different number
End If
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
Re: check a block of files in dir
are you a magician?HansV wrote:Does this do what you want? You'll have to complete the code yourself.
Code: Select all
Sub CheckBlock() Dim strPrefix As String Dim dtmDate As Date Dim strDate As String Dim strFolder As String Dim strFile As String Dim lngCount As Long strFolder = "C:\Dir1\" strPrefix = "50?-L0_" dtmDate = Date ' or DateSerial(2013,3,4) or ... strDate = Format(dtmDate, "dd\-mm\-yyyy") strFile = Dir(strFolder & strPrefix & strDate & ".txt") Do While strFile <> "" lngCount = lngCount + 1 strFile = Dir Loop If lngCount = 4 Then ' We have 4 files matching the pattern Else ' We have a different number End If End Sub
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
Re: check a block of files in dir
to understand ? is similar the *, or not?HansV wrote:Does this do what you want? You'll have to complete the code yourself.
Code: Select all
Sub CheckBlock() Dim strPrefix As String Dim dtmDate As Date Dim strDate As String Dim strFolder As String Dim strFile As String Dim lngCount As Long strFolder = "C:\Dir1\" strPrefix = "50?-L0_" dtmDate = Date ' or DateSerial(2013,3,4) or ... strDate = Format(dtmDate, "dd\-mm\-yyyy") strFile = Dir(strFolder & strPrefix & strDate & ".txt") Do While strFile <> "" lngCount = lngCount + 1 strFile = Dir Loop If lngCount = 4 Then ' We have 4 files matching the pattern Else ' We have a different number End If End Sub
-
- Administrator
- Posts: 78628
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: check a block of files in dir
? stands for a single character, * for any number of characters.
So "S?l" matches "Sal" and "Sol" and "Sql", but not "Sail", nor "Strudel".
On the other hand, "S*l" matches "Sal" and "Sail" and "Sl" and "S456l".
So "S?l" matches "Sal" and "Sol" and "Sql", but not "Sail", nor "Strudel".
On the other hand, "S*l" matches "Sal" and "Sail" and "Sl" and "S456l".
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
Re: check a block of files in dir
NICE EXPLAIN... TKS.HansV wrote:? stands for a single character, * for any number of characters.
So "S?l" matches "Sal" and "Sol" and "Sql", but not "Sail", nor "Strudel".
On the other hand, "S*l" matches "Sal" and "Sail" and "Sl" and "S456l".