heilstalin
heilstalin

Reputation: 31

Generate text up to certain number

So, I have a URL

sub.domain.com/tile/512/0/0/0.jpg?blablabla123

and I need 0/0/0.jpg to go up to 6/43/43.jpg 6 being the highest number for the first place, and 43 being the largest number to go up to on the middle and end numbers in the generated text.

Some examples:

sub.domain.com/tile/512/0/0/0.jpg?blablabla123

...

sub.domain.com/tile/512/0/0/43.jpg?blablabla123

sub.domain.com/tile/512/0/1/0.jpg?blablabla123

...

sub.domain.com/tile/512/0/43/43.jpg?blablabla123

sub.domain.com/tile/512/1/0/0.jpg?blablabla123

How can I do this and output to a file?

Upvotes: 0

Views: 30

Answers (2)

user5283155
user5283155

Reputation:

Here's a node.js script for that.

var fs = require('fs');

var stream = fs.createWriteStream('./urls.txt');
stream.once('open', function(fd) {
    for (var i = 0; i <= 6; i++) {
        for (var j = 0; j <= 43; j++) {
            for (var k = 0; k <= 43; k++) {
                stream.write('sub.domain.com/tile/512/' + i + '/' + j + '/' + k + '.jpg?blablabla123\n');
            }
        }
    }
    stream.end();
});

Upvotes: 1

FriendFX
FriendFX

Reputation: 3079

Just because I have a Python interpreter open...

for a in range(7):
    for b in range(44):
        for c in range(44):
            print('sub.domain.com/tile/512/%(a)d/%(b)d/%(c)d.jpg' % locals())

Save this to a file make_urls.py and then call like follows:

python make_urls.py > my_urls.txt

Hope that helps!

Upvotes: 0

Related Questions