icloud-photos-downloader / icloud_photos_downloader

A command-line tool to download photos from iCloud
MIT License
6.88k stars 553 forks source link

Archiv mode #952

Open Nikongen opened 2 months ago

Nikongen commented 2 months ago

Summary

New CLI option --archive TARGET-FILES ARCHIV-FOLDER to archive a folder/images and delete them from iCloud

Context

I have icloudpd running as a service in copy mode with --auto-delete --watch-with-interval 3600. From time to time I want to archive old photons to free up some space on iCloud. Lets say I want to archive all photons from 2022, my current workaround is:

  1. Stop the icloudpd service
  2. Move the 2022 folder to my archive folder mv icloud-images/2022 icloud-archive/
  3. Run icloudpd in copy mode with --delete-after-download 3.1. Downloads all images from 2022 again and 3.2. Removes them (moves them to deleted album) on iCloud
  4. Remove downloaded images in local 2022 folder rm -r icloud-images/2022
  5. Start service again

With my current solution all images from 2022 are downloaded again, just to be deleted afterwards

Idea

Put this in a CLI mode and remove the need to Download the images again:

AndreyNikiforov commented 2 months ago

IIUC Your goal is to reduce iCloud storage used by photos.

If you are trying to solve that, if would be beneficial a) to list criteria to compare solutions b) to look at a number of possible options and c) to compare options using criteria. There were some ideas posted at this repo already (issues and/or discussions) and you can use them for your analysis. IIRC there were edge cases identified as well, e.g. keeping favorites on iCloud regardless of their date.

Regarding your current workaround: I do not understand how you reach the goal with --delete-after-download, because in that case you will delete all photos in icloud, since we do not have filters by date. If that is indeed what you are doing, then just deleting all photos though icloud.com web UI can achieve the same result (may be that should be yet another option in your analysis?).

Nikongen commented 2 months ago

IIUC Your goal is to reduce iCloud storage used by photos.

Yes + moving photos to my archive

Regarding a)-c): I will check older issues and try to collect related issues in this issue

Regarding your current workaround: I do not understand how you reach the goal with --delete-after-download

I use that icloudpd by default creates a folder structure according to the date (EXIF:CreateDate I assume) of the downloaded images, e.g. 2024/08/16/IMG_1134.HEIC So first running this will save all images/videos from iCloud on my local machine icloudpd --directory icloud-pictures --username me@mail.com

Now I refer to the note in the Docs under Operation Modes

"If remote assets were not downloaded, e.g. because they were already in local storage, they will NOT be deleted in iCloud."

If I move/remove a folder from the my download folder (icloud-pictures) and run icloudpd --directory icloud-pictures --username me@mail.com --delete-after-download all images & videos, that were in this folder will be downloaded again, thus also deleted from the iCloud. All other images already present in the local folder are not affected, as I can see in the output of the command

...
2024-09-14 02:56:12 DEBUG    2024/08/16/IMG_1134.HEIC already exists                         
2024-09-14 02:56:12 DEBUG    2024/08/16/IMG_1133.HEIC already exists                         
2024-09-14 02:56:12 DEBUG    2024/08/16/IMG_1132.HEIC already exists                         
2024-09-14 02:56:12 DEBUG    2024/08/16/IMG_1131.HEIC already exists
...

In conclusion: By deleting the appropriate folder I have a quite granular filter for a specific date, month or year. At least this is how I understood the Docs, commands output

If that is indeed what you are doing, then just deleting all photos though icloud.com web UI can achieve the same result (may be that should be yet another option in your analysis?).

Fair point, though that can be a little tedious depending on the number of photos. I am aiming for a bash script solution that I can run by hand from time to time e.g. the skript archive-icloud.sh shown below

#!/bin/bash
# Create folders
mkdir -p icloud-pictures
mkdir -p icloud-archive
# Download all images
icloudpd --directory icloud-pictures --username me@mail.com
# Move a certain folder to archive 
folder=$1
mv "icloud-picture/${folder}" icloud-archive
# icloudpd in move mode, to delete photos from iCloud
icloudpd --directory icloud-pictures --username me@mail.com --delete-after-download
# remove downloaded photos (as these are already in archive
rm -r mv "icloud-picture/${folder}" 

Now I run

AndreyNikiforov commented 2 months ago

Wow, nice trick with removing local folder and then re-running icloudpd --delete-after-download. I did not get from your first post.