I am having trouble setting a criteria. i have done this with the move utility but does not seem to work with a "if" statement.
the statement in bold should be true as the current file name is set to "c:\prod\cool\03_a_book.DOC"
but it is still coming out false.
is there a wild card function that is different than"?"
any suggestions?
Code:IfFileExists>C:\Prod\COOL\*.DOC,
GetFileList>c:\prod\cool\*.doc,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
let>Path=c:\prod\cool
goto>file_Counter
endif
label>file_Counter
Let>k=0
Let>k=k+1
let>current_File=file_names_%k%
goto>check_Feed
label>check_Feed
MessageModal>this is what i am Trying to comparing: %current_File% = %path%\???a?????.DOC
if>%path%\???a?????.DOC=%current_File%,
goto>feed_A
endif
issue using a criteria on a file name with an if statment
Moderators: JRL, Dorian (MJT support)
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
You can't use IfFileExists with a wildcard, it has to be a file name. The solution is to do the GetFileList> with a wildcard and then test the value of file_names_count with an If> to see of there are any matching files.
Code: Select all
GetFileList>c:\prod\cool\*.doc,files
Separate>files,;,file_names
If>file_names_count>0
//rest of your code
You can't use wildcards in an If statement. You need to write all the code to emulate a wildcard comparison. Regex could possibly shorten the following but stretching out the steps it might make the process easier to understand.
Code: Select all
VBSTART
VBEND
//why not set the path early to make it easily changeable?
let>Path=c:\prod\cool
GetFileList>%path%\*.doc,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
//You need to keep the let k=0 line out of the loop
Let>k=0
label>file_Counter
Let>k=k+1
let>current_File=file_names_%k%
goto>check_Feed
label>check_Feed
Label>Step1
//eliminate matching case issues by converting all to upper case
VBEval>ucase("%path%"),path
VBEval>ucase("%current_File%"),current_File
Label>Step2
//Check to see if the path is in the current file name
Separate>%current_File%,%path%\,name
If>name_count>1
//If count is greater than 1 the path is in the current file name
Goto>Step3
Else
//Else path does not match
goto>file_Counter
EndIF
Label>Step3
//Check to see if the file extension matches
Separate>%name_2%,.,part
If>%part_2%=DOC
//extension matches
Goto>Step4
Else
//Extension Does not match
goto>file_Counter
EndIf
Label>Step4
//Check to make sure file name less extension is 9 characters long
Length>%part_1%,len
If>len=9
//length is right
Goto>Step5
Else
//length is wrong
goto>file_Counter
EndIf
Label>Step5
//Check to make sure the fourth character is an "A"
Midstr%part_1%,4,1,char
If>char=A
//Fourth character is an "A" and the file meets all criteria
goto>feed_A
Else
//Fourth character is not an "A"
goto>file_Counter
EndIf