Skip to content

Instantly share code, notes, and snippets.

@novogrammer
Created February 17, 2023 11:19
Show Gist options
  • Save novogrammer/c10a0ea2af505f2b1b0edcefcfa0a360 to your computer and use it in GitHub Desktop.
Save novogrammer/c10a0ea2af505f2b1b0edcefcfa0a360 to your computer and use it in GitHub Desktop.
download100images.mjs
import {execSync} from "child_process"
function zeroPadding(num, qty) {
return `${"0".repeat(qty)}${num}`.slice(qty * -1);
}
async function main(){
for(let i=0;i<100;i+=1){
const text=`image${zeroPadding(i,2)}`;
const filename=`${text}.jpg`;
const encodedText = encodeURIComponent(text);
const url = `https://dummyimage.com/600x400/000/fff.jpg?text=${encodedText}`;
const command=`curl "${url}" -o ${filename}`;
execSync(command);
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment