Skip to content

Archiving Videos from Amazon Photos

Tags: javascript • Categories: Productivity

Table of Contents

Amazon Photos is a good-enough product for video storage. The interface is pretty bad, they don’t have an API, they don’t add new features, but they have unlimited photo storage with Prime, their mobile backup app is decent, and they have easy photo printing options.

However, they do not make it easy to bulk download photos or videos. These two scripts, which you can copy/paste into your web console, make it easy to "select all" on a specific filter and download your videos + photos from Amazon Photos.

Select all photos or videos to download

It’s frustrating, but Amazon Photos does not allow you to "select all" when you are looking at a filtered set of photos or videos. This script is basically a "select all" command for Amazon Photos.

lastScrollPosition = -1;

interval = setInterval(() => {
    // Click all the selection buttons that are not already selected
    document.querySelectorAll('.count-select:not(.active)').forEach(button => button.click());

    // If the scroll position hasn't changed since the last interval, then we are done
    if (lastScrollPosition === window.scrollY) {
        console.log('Interval cleared - No further scrolling detected.');
        clearInterval(interval);
        return;
    }

    // Update the last scroll position.
    lastScrollPosition = window.scrollY;

    // Wait for 100ms, then scroll by half the viewport's height.
    // Why half? Why not. Random number to avoid weird react loading glitches.
    setTimeout(() => {
        window.scrollBy(0, window.innerHeight / 2);
    }, 100);

}, 1000); // Repeat every 1 second, increase if you are on a slow connection

Download all archive splits

Amazon photos breaks up selected photos into multiple archives when the selected photos are big. This script will incrementally download each one so you don’t have to click a ton of different links.

downloadLinks = document.querySelectorAll('.download-link .download');

console.log(`Total link count: ${downloadLinks.length}`);

function clickLink(index) {
    // Stop if we've clicked all links.
    if (index >= downloadLinks.length) {
        console.log('All links have been clicked.');
        return;
    }

    downloadLinks[index].click();

    // Wait for 2 seconds before clicking the next link.
    setTimeout(() => {
        clickLink(index + 1);
    }, 2000);
}

// Start clicking from the first link.
clickLink(0);

After you download all of the "splits" you may want to flatten all of the different folders into one. Assuming that the split folders are all under a common parent folder, you can use the following script to flatten the folder structure and then remove the empty folders (make sure you know what you are doing as this can be dangerous):

fd -t f --min-depth 2 --exec mv {} ./
fd -t d -E ".*" --exec rmdir {}

Bonus: flattening folders, selecting all images on Google Photos

Automatic scrolling didn’t work on Google Photos, but here’s a snippet to select all of the checkboxes:

document.querySelectorAll("div[role='checkbox'][aria-checked='false']").forEach(button => button.click());

Keep in Touch

Subscribe to my email list to keep in touch. I’ll send you new blog posts and other thoughts.