Alternative to Nested Loop

amjwh99

New Member
Hi,

I have a process where I add an excel spreadsheet to a collection (C1). The spreadsheet contains a list of file names. I then create another collection (C2) that contains all file data from a specific directory.

Then, I have a nested loop that loops through both collections on the file name. If a file name from C2 matches a file name from C1 that file is moved to another directory. Everything works brilliantly. However, recently I encountered a situation where I had 200 file names in C1 and 600 files in C2. The loop took forever to run.

Any suggestions on a more efficient way to handle this?

View attachment bp-example.png
 

Sukesh Kumaru

Active Member
Hello,
By using VBO called utility file management and Action: Get files to fetch all filenames from a folder and do collection comparison operation between 2 collections and which ever matches copy that to 3rd collection and finally perform file move operation.
 

amjwh99

New Member
Hello,
By using VBO called utility file management and Action: Get files to fetch all filenames from a folder and do collection comparison operation between 2 collections and which ever matches copy that to 3rd collection and finally perform file move operation.

Understood. That's essentially what I'm doing already. When you say collection comparison, do you mean to use a loop?
 

amjwh99

New Member
You could try

Business Object Utility - Collection Manipulation
Action Collection Contains Value

Thanks for the suggestion. I tried using it but it doesn't work. The match is found, but there is no way to output the file path to prepare to move the file.
 

VJR

Well-Known Member
Hi amjwh99,

The action that @Stephen Jones has suggested is a perfect one based on the requirements in the original post.

"The match is found, but there is no way to output the file path to prepare to move the file. "
What does this exactly mean? Are you having a file path in some other column (of which collection C1 or C2?) and you need that file path to move the file. You are unable to get this path without looping? Is that the case?
 

Sukesh Kumaru

Active Member
Thanks for the suggestion. I tried using it but it doesn't work. The match is found, but there is no way to output the file path to prepare to move the file.
Try to extract the column value which has full filepath in the collection where you got all the file details from a folder.
 

amjwh99

New Member
Hi amjwh99,

The action that @Stephen Jones has suggested is a perfect one based on the requirements in the original post.

"The match is found, but there is no way to output the file path to prepare to move the file. "
What does this exactly mean? Are you having a file path in some other column (of which collection C1 or C2?) and you need that file path to move the file. You are unable to get this path without looping? Is that the case?

Correct. To create collection C2, I'm using the following action Business Object: Utility - File Management, Action: Get Files. The collection that's created contains the file path.

The issue I'm experiencing with Business Object Utility - Collection Manipulation, Action Collection Contains Value is that I need to figure out how to output all the data (essentially, I just need the file path) from C2 when a match is found.

There is a "Groups" Collection output, but nothing is outputted when a match is found.
 

Attachments

  • collection-contains-value.png
    101 KB · Views: 55

VJR

Well-Known Member
Hi amjwh99,

If 'Collection Contains Value' is not giving the expected results then you can filter the value and then the result (if match found) will be returned to another collection from which you can read the file path (without a loop).
Your diagram will almost be the same as in Post #4 here.
Post back if you are facing any issues in applying the same logic.
 
Top