Skip to content

Instantly share code, notes, and snippets.

@mubbo
Created June 7, 2021 10:35
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save mubbo/81273206a2bad430b4bfc4f00f9d5e96 to your computer and use it in GitHub Desktop.
Save mubbo/81273206a2bad430b4bfc4f00f9d5e96 to your computer and use it in GitHub Desktop.
download images from shopify shop
function fetchPageAssets() {
let images = document.querySelectorAll('img[src*=files]');
images.forEach(function(image) {
files.push('<a href="' + image.src.replace(/_60x60/, "") + '"><img src="' + image.src.replace(/_60x60/, "") + '">');
});
}
function downloadListFile() {
let button = document.createElement("a");
let data = 'data:application/octet-stream;base64,' + window.btoa(files.join('\n'));
button.id = "download-file";
button.href = data;
button.download = "shopify-files.html";
document.querySelector("body").append(button);
button.click();
}
var files = []
files.push('\n')
fetchPageAssets()
files.push('\n\n')
downloadListFile()
@mubbo
Copy link
Author

mubbo commented Jun 7, 2021

In the files list add ?limit=250 to show the maximum number of files allowed per page.

/admin/settings/files?limit=250

after the page has reloaded paste the above snippet into the console and hit enter.. a new html page should automatically be downloaded to your machine called "shopify-files.html" open this page.. all images should now be available. In your browser choose "Save Page As" complete web page.. this will download all the images to your machine.

@jcontonio
Copy link

You are a treasure. Thank you! 😍

@vlinas
Copy link

vlinas commented Sep 16, 2021

Is there any way to edit this script and get all video mp4 files?

@brandammo
Copy link

legend

@juanengineer
Copy link

So Awesome. Thanks Gary!!!!

@rbnali
Copy link

rbnali commented Jul 5, 2022

@mubbo : do you know what needs to be edited in this script to include mp4 and svg files?

@jeanandrev
Copy link

That worked a treat! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment