Read the Nth line in a text for subsequent KM processing

Thanks in advance, I always get wonderful advice here!

I’m trying to write a KM macro that takes a bunch of URL’s (I presumed to dump them as a list into a text file, but I am open to other better ideas), and then one-by-one, takes the URL, opens it in a browser, gathers some info along the way, and does some other things to it. Then after doing that to the first URL, the macro should move to the next URL in the list, and do the same things to that URL, and so on… and so on… until completed.

Let’s say the text file (I’ll call it “FiveURLs.txt”) has this text in it below. Realistically there will be 100’s of URL’s in the list, but as a simple example:

I want to take, do some things, then take, do the same things, etc etc etc down the list.

I started to have a “For Each Item in a Collection Execute Action” step, like:

For each %Variable%URL% in these collections:
The lines in File: FiveURLs.txt

…and here’s where I’m getting stuck. I’d like to sequentially (on each pass through the macro) assign the URL’s on line 1, line 2, line 3, line 4, and line 5 to a variable for further processing.

My first thought was to “Read File FiveURLs.txt to Variable”, but the problem is that reads the entire set of URL’s to the variable, not only the one line/URL we’re currently concerned with on this specific Nth pass through the macro.

This smells like a RegEx thing, but given that there will likely be 100’s of lines in the real-world example, I don’t know how to attack the problem from that angle.

Is there an easy way to read specific lines of text to a variable as you travel down the lines in a For Each loop?

Or, any ideas how to better do this? Thanks.

Hey Tim,

That's quite easy:


How are you planning to process your URLs?

With Safari or Chrome?

With cURL?

What sort of information are you trying to harvest?

Best Regards,

1 Like

It should be For Each Variable “URL”

Ie, the name of the variable will be just “URL”.

You use the %Variable%URL% in the places you would use the URL later,

Thanks, to both of you. Your clear and straightforward answers got me through this and I’m all done with what I needed. (P.S. Chris, I’m using Chrome, figured it all our based on your & Peter’s answers.)