I've taken @to4kawa 's initial query and made modification to what you're looking for
| makeresults count=10000
| eval COMMENT= "Randomly generate file names with the below string names"
| eval File="string_1L_".(random() % 8)
| eval File="string_L_".(random() % 8)
| eval COMMENT= "For filename with string_1L_2 create file in series from 20-28"
| append
[| makeresults
| eval counter=mvappend("0",mvrange(1,8),"8")
| mvexpand counter
| eval File=trim("string_1L_2".counter,"1")
| table File]
| stats count by File
| eval COMMENT = " Have replaced searchmatch function with match function using regex to check if you've a file with the particular string. This avoids multiple checks. You can replace the regex .*string_1L_2.* with .*string_1L_ .* and this will match with all values that get generated above, to test further."
| eval FileExists=if(match(File, ".*string_1L_2.*"),"Yes", "No")
| table File FileExists
The eval I've above for File Exists, effectively replaces what you're doing here:
| eval keyword=case(searchmatch("string_1L_2"),"string_1L_2",searchmatch("string_1L_21"),"string_1L_21",searchmatch("string_1L_22"),"string_1L_22",searchmatch("string_1L_23"),"string_1L_23",searchmatch("string_1L_24"),"string_1L_24")
| eval Filestatus=if(like(keyword, "string_1L%"), "fileFound", "Filenotfound")
You can add in your Filesize check after that.
... View more