[Solved] How to Open X Number of URLs at a Time in Order From a Master List?

I have a master list of 50 URLs, and I want to open 6 URLs at a time whenever macro is triggered.

When next time same macro is triggered, I want the next 6 URLs to open, and so on.

In the last set i.e. a set of URLs after 42-48, macro may open just 2 URLs 48-50 or go ahead and open total 6 URLs fetching URLs from the beginning of the list (i.e. opening URLs 49, 50, 1, 2, 3, 4). I am fine either way.

How to achieve that?

Sharing a set of actions that I currently use in a different macro. This is near to what I'm trying to achieve. Sharing this in case this is helpful in any way to achieve what I asking in this question.


Links opening.kmmacros (27.8 KB)

Macro Image

Solved by @noisneil @tiffle and @Zabobon

See if this works for you:

Open URLs in Batches.kmmacros (30 KB)

Macro screenshot

5 Likes

Here's my take on your problem.

Test Circular Chunks.kmmacros (5.4 KB)

Click to see macro

Keyboard Maestro Export

The two actions in red let you specify the number of URLs to be opened each time (the "chunk size") and the name of the file containing the list of URLs themselves. You can freely change these to suit your needs.

Each time the macro is run it takes the first chunk size number of lines from the list and opens them in your default browser (the magenta-coloured action). At the same time it rewrites the file containing the list so that those URLs just opened now appear at the end of the file. That means the list behaves in a circular manner.

I hope you find it useful.

Here's the list of URLs that I used:
KM Test List.txt.zip (799 Bytes)

EDIT
I've turned this into a general-purpose subroutine that allows the list to be "circular" or not as required. You can find it here:

7 Likes

And here is a version that uses a Keyboard Maestro Dictionary.

The first Magenta coloured list at the top can be updated with whatever list of URLs you want.

The second Magenta Action sets the number of each batch of URLs to open (i.e. 6).

EXAMPLE Open in Batches of 6 URLs from List.kmmacros (10.4 KB)

Click to Show Image of Macro

4 Likes

Thank you so much @Zabobon @noisneil and @tiffle for sharing the macro.

I am going to use the one shared by @tiffle because it gives an additional opportunity to use a file which I can append URLs to using siri shortcuts from iPhone too, which can be handy in my use case.

Thanks a ton!

1 Like

It’s nice to have a choice!!

1 Like

For what it's worth, you can do that with any of them by reading the initial variable from a file using the Read a File action.

Open URLs in Batches (Read File).kmmacros (31 KB)

Macro screenshot

The only difference is that with @tiffle's version, the file will be shuffled every time the macro runs, by sending the URLs just opened to the end of the list.

Visual Explanation

This means that those URLs will be opened again before any newly added ones. Whether that's of benefit or detriment to your workflow depends on how you'd like it to work.

Thanks for giving further explanation.

I'll keep this in mind. For the current use case, I'm neutral about whether or not newly added URLs open first.

But will definitely refer to your response if I need it for a different use case. Thank you :slight_smile:

1 Like

In addition no global variables are used as I’ve developed a definite dislike of them :wink:

3 Likes