For each loop, run item & path at the same time in For each loop

I would like to loop through ITEM & PATH at the same time… how is that possible?

Screenshot 2021-03-02 at 10.10.05|291x500

Hi @Nightowl_music

Do u mean u need to iterate both arrays within one for each loop ?

yes both arrays

What is the use case here ?
You can use Parallel for each for instance but it will go one by one on each item in both loops

I have pdf & rtf files. first im using Regex for the pdf file… to get a number. second I need the path of the pdf & rtf files to upload.

all these actions I want in 1 For Each Loop

Assuming you have both files in one folder, Follow below steps

  1. Read all files from folder
    listFiles=directory.getfile(“FolderPath”)
  2. u can get count by below code
    rtfCount=(for i in list file where i.tostring.contins(.rtf) select i).count
    pdfCount=(for i in list file where i.tostring.contins(.pdf) select i).count

here i is filepath of all files whether rtf or pdf

I under standard the directory.getfile.

but not the count code.

how to write these?

Hi @Nightowl_music - You want to get the rtf files & pdf files count?

IntPDFCount = Directory.GetFiles(YourPath,“*.pdf”).Count

IntPDFCount is of variable type Int32.

Similarly you can get the count for rtf files.

1 Like

If u need to iterate both just place one for each inside the other. You can change “item” for example to file and in second to path. Then you will be able use one of them in both for each iterates.

If you have files in folder and u need to have filename and path to that file just create one for each loop and before it create array with paths (value: directory.getfiles(path to folder)) and put it to for each. Then inside of that loop u can put variable with value: Path.gefilename(item) so u will have file name. If file name (as string) contains “.pdf” u can read what you want.

Based on your description I can’t help more, because I don’t understand what you need to do :wink: