Jump to content
UBot Underground

Compare Lists - Performance to slow


Recommended Posts

Hello.

 

I have two list with file paths and file names.

 

Example:

d:\files\info.exe
c:\test\hallo.exe
 
 
The first list is my source list. And I want to identify if items from my second list are included in list1.
 
 
Here is my current code:
 
set list position(%file1, 0)
set list position(%file2, 0)
loop($list total(%file1)) {
    set list position(%file2, 0)
    loop($list total(%file2)) {
        set(#xxxx, $find regular expression($next list item(%file2), "(?<=\\\\)[a-zA-Z\\s]+\\.exe"), "Global")
        if($comparison($find regular expression($next list item(%file1), "(?<=\\\\)[a-zA-Z\\s]+\\.exe"), "=", #xxxx)) {
            then {
                alert("juhu")
            }
            else {
            }
        }
    }
}

My first list has 100 files. And the second one 30. So that 100x30 loops. 

 

If there is a match, I need the full path+filename from the match in the file1 and the file2 list. So I can not just edit the list to only include the filenames. 

But the matching must be done only by the filename because the folders will be different.

 

 

Any idea how the speed could be improved here?

 

Thanks in advance for your help

Dan

 

 

 

 

Link to post
Share on other sites

Hi,

 

Changed:

1. loop to loop while. Should exit loop while on match.

2. $find regular expression to $replace regular expression.

3. Added if then else checks to avoid exceed list error

 

Code:

set list position(%file1, 0)
set list position(%file2, 0)
loop($list total(%file1)) {
    if($comparison($list position(%file1), "<", $list total(%file1))) {
        then {
            set(#xxxx, $replace regular expression($next list item(%file1), ".*\\\\", $nothing), "Global")
            set list position(%file2, 0)
            set(#foundmatch, $false, "Global")
            loop while($both($comparison(#foundmatch, "=", $false), $comparison($list position(%file2), "<", $list total(%file2)))) {
                if($comparison($list position(%file2), "<", $list total(%file2))) {
                    then {
                        if($comparison($replace regular expression($next list item(%file2), ".*\\\\", $nothing), "=", #xxxx)) {
                            then {
                                alert("juhu {#xxxx}")
                                set(#foundmatch, $true, "Global")
                            }
                            else {
                            }
                        }
                    }
                    else {
                    }
                }
            }
        }
        else {
        }
    }
}

Kevin

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...