Giter VIP home page Giter VIP logo

google-photos-delete-tool's Introduction

Google Photos Delete All Tool

If you have ever wanted to delete your thousands of photos from the Google Photos but failed to find an easy way to do so, then this is the tool for you. This script goes through all your photos in Google Photos app on the desktop and deletes them. You can visually see the process while it happens!

Getting Started

Follow the step-by-step instructions below to run the tool.

Prerequisites

Assumptions

The manual steps assume that these steps are performed on the Google Chrome Browser. If you're using a different browser, the steps still remain the same, however, the keyboard shortcuts or browser specific keywords may not be same for you, as described below.

Steps

  1. Login into your Google Account.

Google Account Sign-in Page

  1. Go to Google Photos

Google Photos Page

Note: If you're logged into Google, you will see your images. Note: You must login into English language version of Google Photo

  1. Disable image loading for Google Photos on your browser to avoid high cpu,ram and network usage

    • On Chrome

      1. Click on the site padlock ( the lock icon along the url bar) -> Site settings

      2. Block images in the Permissions for the website

      Google Chrome Right Click Pop-up Menu

      1. Reload Google Photos
  2. Open Developer Tools. You can do so by following either of the three options

    • Keyboard Shortcut

      Press the three keys together in the sequence - CTRL + SHIFT + I

    • From the Page

      Right click on an empty area with your mouse and select Inspect (last option)

      Google Chrome Right Click Pop-up Menu

    • From Menu

      1. Click on the menu button Google Chrome Menu Icon on Google Chrome (By default, the button is present on the top right corner of the window).

      2. Select More tools.

      3. Select Developer tools.

      Google Chrome Menu Developer Tools

  3. After opening the developer tools, click on the Console tab. Google Chrome Console on Google Photos page

    Note: This console lets you run custom code, like this tool! You can learn about it on Google Console page.

    You will see a warning from Google to stay cautious. If you run code in this console that's malicious, you could be hacked. Therefore, make sure that you only run the code that you understand.

  4. Copy all the code in the file delete_photos.js and paste it in the console. The Code in Chrome Console

    Note: The script allows you to delete all photos or any number of photos. To delete a specific number of photos, change the value of maxImageCount as provided in the example.

  5. Hit ENTER button after pasting the script in the console. The script will start running upon hitting ENTER key.

  6. Done! Now, you should see the script delete all your photos in the batch

Go Faster Option

Script selects and deletes photos in batches based on what can be seen in the browser at one time. To increase the amount of photos that can be seen at once, and therefore deleted per batch, zoom out.

- **Chrome on Windows and Linux**

    Control-Minus to zoom out.

- **Chrome on Mac**

    Command-Minus to zoom out.

Debugging

The script may not work as expected in case your internet speed is considerably slow. In that case, you may want to increase the DELETE_DELAY_CYCLE by few thousands of milliseconds. This is to ensure that the page has refreshed before the tool tries to delete the images again.

FAQs

  1. It checks and unchecks the photos, but doesn't delete them.

  2. It stops after deleting some images.

    • Increase the DELETE_DELAY_CYCLE by thousands of milliseconds as described in the Debugging section.
  3. There was a delay in loading images and the tool exited.

    • In case this happens, you can simply paste the script again and hit enter. The script will continue doing the operation. If you're using, you wouldn't have to copy and paste again. If you press the up arrow key, it will load the last command that you ran in the console. Hit ENTER key and the script will start again.

google-photos-delete-tool's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-photos-delete-tool's Issues

Easier and faster to just hold shift and scroll down?

Good script... tried it, then realized it's actually not bad to delete thousands of photos anymore via the UI... maybe they've pushed some UI updates to improve this UX without actual "delete all"?

  1. Click the checkmark on the first image
  2. Hold shift
  3. Scroll down about 500 or so pics (not too much though or this won't work)
  4. Let the UI finish loading for a couple seconds
  5. Still holding shift, notice on hover that checkmarks shade-in for all photos between 1 and wherever you're at in the scroll
  6. Click on a photo, hold shift again and scroll down some more click, repeat... (if you don't see it highlight more, just go back up and click what you missed... the checkmarks don't go away)
  7. Hit delete

I just deleted 23,000 photos in about 3 minutes. Might be worth a try 😄

Sleep when no checkboxes have been found

Maybe sleep some time when no checkboxes have been found so that the page can properly load:


    do {
        checkboxes = document.querySelectorAll(ELEMENT_SELECTORS['checkboxClass']);
		if (checkboxes.length <= 0)
			Sleep(2000); 
    } while (checkboxes.length <= 0 && attemptCount++ < MAX_RETRIES);

How to restart tool

Can we add instructions on how to restart the tool? If there is a slowdown to loading the next set of photos, the tool logs that is has exited.

But how can I restart manually other than doing a full reload and pasting the script?

Thanks!

Delete only photos/videos that are not part of a shared album

Thank you for building this.
As I would like to liberate space on my Google account, I'd like only to delete photos and videos that are not part of a shared album.
Because if I delete all the photos, they will also be deleted from the shared album.

Intelligently wait until previous deletion has completed

Thank you for this tool!
I am here to suggest an improvement.

The current iteration with timers between deletion cycles is somewhat clunky, and does not take machine performance and network latency into account.

Recommended change is to wait until the "Moving X images" prompt disappears from the DOM before attempting the next deletion cycle.

Add delete album/folder feature.

Hey bro thanks for the awesome script.

I wrote a quick one to delete the folders/albums as well (maybe you can add it as a feature).

It probably needs some tweaking to make sure it runs smoothly on slower computers.

Here is the code:

var intervalId = window.setInterval(function () {
deleteAlbum()
}, 6000);

var albums = 0;
var albumNumber = document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb').length;

function deleteAlbum() {
// Get our first album and click it
setTimeout(function () {
document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb')[2].click();
}, 500);

setTimeout(function () {
    document.getElementsByClassName('z80M1 o7Osof')[6].dispatchEvent(new MouseEvent("mousedown", {
        bubbles: true,
        cancelable: true,
        view: window
    }));
}, 1500);


// Get our delete button and click it
setTimeout(function () {
    document
        .getElementsByClassName('z80M1 o7Osof')[6].dispatchEvent(new MouseEvent("mouseup", {
        bubbles: true,
        cancelable: true,
        view: window
    }));
}, 2500);


// Confirm deletion
setTimeout(function () {
    document
        .getElementsByClassName('VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ nCP5yc AjY5Oe kHssdc HvOprf')[0].click();

}, 4000);

// Confirm deletion
setTimeout(function () {
    currentAlbums = document.getElementsByClassName('U26fgb JRtysb WzwrXb YI2CVc G6iPcb').length;
    console.log("Current album number: " + currentAlbums);
    console.log("Old album number: " + albumNumber)
    if (currentAlbums < albumNumber) {
        albums++;
        console.log(albums + " deleted.");
    } else {
        console.log("Error deleting album. Aborting")
        clearInterval(intervalId)
    }
}, 5500);

}

Need to manually click delete button each time

Great script! I'm seeing that after it runs the select on all of the photos, you get a prompt in the corner asking you to delete. If you don't manually click on delete it then just unselecting everything after a few seconds and does the same again in a cycle. If it was possible for it to select and click the button too so the process could be fully automated and left to run by itself

For You section

hi!

first of all THANKS for this, it was very helpful and I deleted all my pictures there. However they still remain in the "For you" section and in "view unsaved or disssmised creations" section (link on the very bottom of the "For you" section page.

I am sure they do this for purpose.

Would it be possible to have deletion robots for those two parts. By that the cleaning would be complete.

It did not helped

Hi, this script did not helped for me. Chrome version 80.0.3987.163 , no photo was deleted. Why ??
I attached one file - do you see a bug ? Where is the problem ?
screen

Language problem

Delete button does not work if you are using google photo's in another language.
This is because the button is not titled "Delete" in other languages, but "Verwijderen" in dutch for example.

Can be fixed by using a direct path to the button itself, rather then searching for a title.

Confirmation button not getting pushed

Hi- First let me say thank you for building a tool that solves a big problem for me. I understand that providing this tool can be a bit or a lot of work for you. I used the tool a few days ago and now today when I try it doesn't click the "Remove from Google Account, Google Drive, synced devices and places where it's shared?" button and when the script is running the title of the box that is display sayd "unused". I think this is property span.Vfpkd-vQzf8d and maybe a new one since it seems I had shared this photo.

Select all photo script

let t = 0
while (true) {
  let checkboxes = [...document.querySelectorAll('.ckGgle')].filter((x) => x.ariaChecked == 'false')
if (checkboxes.length > 0) {
    t = 0
  checkboxes.forEach((x) => x.click());
  document.getElementsByClassName("yDSiEe uGCjIb zcLWac eejsDc TWmIyd")[0].scrollBy(0, window.outerHeight);
} else {
    t++;
    if (t > 30) break
}
    await new Promise(resolve => setTimeout(resolve, 100));
}

enjoy

Thank You

Sorry to make an issue to do this, but not sure another way to get in touch. Trying to leave Google Photos is such a pain and your solution here helps automate a mundane task wonderfully. Thank you for giving me a way to exit Google Photos and all the privacy ramifications of keeping entire libraries on their servers. Take Care!

Doesn't seem to work.

I added the code in a snipet.
I see the photos get selected, then they get unselected. They get selected again, etc.

Not an issue. Just thanks!

Holy crap dude. Thank you so much for this. I was really hating manually deleting my thousands of photos manually, You're a lifesaver! Thank you so much!!!

Selects images, doesn't seem to delete them

I increased the timeouts by a factor of 2X. I see the photos selected, but I don't see the delete actions occur.

Rather it seems to repeatedly: Select the same images, clear upon deleation, and select those images again.

I checked and my language was set to US English. I set to English and the behavior was the same.

Maybe a side effect of using Chromium vs. Chrome?

Version 89.0.4389.82 (Official Build) Arch Linux (64-bit)

Not Clicking Confirmation Button

Thank you for this wonderful tool. For whatever reason, the script does not seem to click the confirmation button. I looked at the issue opened by MickPBduece but was not able to see a solution in his notes.

Tool only selecting 10-20 pictures at a time

Hi,
Great tool!
Too bad we need it... Google should really implement a proper delete tool in the app it self...

But... the tool takes forever if you have many pictures... 7 seconds per round means ~7000 pictures per hour (15 pic/round average).

It would be really great if the tool could select perhaps 500 pcs per cycle...

/th

If it just checks and unchecks photos..

replace this:
deleteButton: 'button[title="Delete"]',

with your language. hover on delete button to see the translation. it doesn't work if your account isn't in English language

if it doesn't click confirmation button, there's pull requests for that

Problems with the script

I get the following message repeatedly:
[INFO] Deleting 29 images debugger eval code:36:13
[INFO] Deleting 29 images debugger eval code:36:13
[INFO] Deleting 29 images debugger eval code:36:13

and the script actually never deletes any images. It marks images, but does not delete them.

Any help?

PS: I have tried it on both OSX and win10, firefox and chrome (latest versions). Same results. I need to delete approximately 200,000 images...

"No More Photos Left To Delete"

I have like 40k photos, it went through about 200 (in selection bulks of about 25) then stopped and said there are no more photos to delete.

Zoom out --> selects more photos at once

FYI:

When I first ran the script it would delete 35 photos at once.
I then zoomed out (Command + Minus) which resulted in over 800 images being deleted at once.

That might be of interest for the guide.

Thank you for providing your script.

Confirmation button changed, doesn't delete photos

confirmationButton: '#yDmH0d > div.llhEMd.iWO5td > div > div.g3VIld.V639qd.bvQPzd.oEOLpc.Up8vH.J9Nfi.A9Uzve.iWO5td > div.XfpsVe.J9fJmf > button.VfPpkd-LgbsSe.VfPpkd-LgbsSe-OWXEXe-k8QpJ.nCP5yc.kHssdc.HvOprf'

This line doesn't appear to find the confirmation anymore, perhaps the text has changed? This means that the photos are checked, the trash icon is clicked, but then the photos are never moved to the trash. Sadly I don't know enough JS to adjust to the new value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.