Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archiv mode #952

Open
Nikongen opened this issue Sep 13, 2024 · 3 comments
Open

Archiv mode #952

Nikongen opened this issue Sep 13, 2024 · 3 comments

Comments

@Nikongen
Copy link

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:

  • Take a folder name or regex for files as argument
  • For each file in Folder/that matches regex
    • Search the file on iCloud
    • If found, delete on iCloud
    • Move local copy to archive folder
@AndreyNikiforov
Copy link
Collaborator

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
Copy link
Author

Nikongen commented Sep 13, 2024

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 [email protected]

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 [email protected] --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 [email protected]
# 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 [email protected] --delete-after-download
# remove downloaded photos (as these are already in archive
rm -r mv "icloud-picture/${folder}" 

Now I run

  • archive-icloud.sh 2022 to archive photos from a specific year
  • archive-icloud.sh 2022/09 to archive photos from a specific month
  • archive-icloud.sh 2022/09/05 to archive photos from a specific date/day

@AndreyNikiforov
Copy link
Collaborator

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

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

No branches or pull requests

2 participants