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

Add --not-album ALBUM to find photos not in a given album #1685

Open
RhetTbull opened this issue Sep 16, 2024 · 9 comments
Open

Add --not-album ALBUM to find photos not in a given album #1685

RhetTbull opened this issue Sep 16, 2024 · 9 comments
Labels
cli Pertains to the command line interface feature request New feature or request

Comments

@RhetTbull
Copy link
Owner

This will simplify excluding specific albums from the export.

Alternative is to use --query-eval " 'ALBUM' not in photo.albums"

@RhetTbull RhetTbull added feature request New feature or request cli Pertains to the command line interface labels Sep 16, 2024
@petebocken
Copy link

Thanks @RhetTbull for working on this! Question on using --query-eval... I have an album named All-Photos. I'm using --query-eval " 'All-Photos' not in photo.albums". The All-Photos album does not get exported, but now my export consists of just a few of my total albums, folders and photos.

@RhetTbull
Copy link
Owner Author

What's the full export command line you're using?

@petebocken
Copy link

What's the full export command line you're using?

I'll just post my entire script for clarity:

#!/bin/bash

OSXPHOTOS="/Users/peter/.local/bin/osxphotos"
DIRECTORY="/Volumes/Photos/Photos Export/"
LOG="/Users/peter/Library/Mobile Documents/com~apple~CloudDocs/Tech/Scripts/osxphotos/osxphotos.log"

# Clear log
echo "" > "$LOG"

# Add date to log
date >> "$LOG"

# Run osxphotos
"$OSXPHOTOS" export --query-eval " 'All-Photos' not in photo.albums" --download-missing --not-syndicated --not-shared --skip-original-if-edited --update --cleanup "$DIRECTORY" --directory "{folder_album}" --no-progress >> "$LOG"

@RhetTbull
Copy link
Owner Author

@petebocken I have not been able to reproduce this. I create an album "All-Photos" and added some photos then ran the same command you are using. The export worked as expected -- all albums were created with exception of "All-Photos" and all photos were exported with exception of those in "All-Photos".

I will keep tinkering but I can't think of a reason at the moment for the issue you're seeing. What version of macOS are you using? If on macOS 15, there's a bug discovered today (#1687) that affects some edited photos but I don't think it would affect your use case.

@oPromessa
Copy link
Contributor

The All-Photos album does not get exported, but now my export consists of just a few of my total albums, folders and photos.

Hello. Maybe adumb question! Would it be related with pics belonging to multiple Albums?

  • @petebocken Are the pics that are actually being exported not in the All-Photos album at all?
  • @petebocken Are your non exported pics in other Albums while part of All-Photos album also?

@RhetTbull
Copy link
Owner Author

I think @oPromessa may be on to something. @petebocken if your "All-Photos" album really contains all (or most) of the photos in the library then the use of --query-eval excludes these photos from the export set (meaning the photos in the All-Photos album will not be exported at all) which sounds like what you're seeing. From your question, I assumed that was the intended behavior: "do not export any photo that is in the 'All-Photos' album" which is what the --query-eval does.

However, if what you really meant was "All my photos are in 'All-Photos'. Some photos are also in one or more other albums. I want to export those albums and all the photos not in them but not the 'All-Photos' album" then that's a different problem and I don't have a full solution.

One means to do this is to use a --directory template. Instead of {folder_album} as you're currently using (which evaluates to all albums a photo is in), you could exclude the All-Photos album from the list generated by the template:

--directory "{folder_album|remove(All-Photos),}"

This removes 'All-Photos' from the list of folders/albums. However, in the case where you have photos that were only in All-Photos, those photos now will still get exported, either in the root folder of the export or in the default folder (_ unless you have specified something different). For example:

--directory "{folder_album|remove(All-Photos),}" adds a comma with nothing following it which says "don't use a default" and that means those photos won't get a folder name assigned and will be dumped in the root of the export folder.

--directory "{folder_album|remove(All-Photos)}" excludes the default value and preceeding comman and thus the default will be _ which is the OSXPhotos template default when no value is specified.

--directory "{folder_album|remove(All-Photos),All-Photos}" uses All-Photos as the default and this is thus the same as using {folder_album}

However, we can combine this with a new --query-eval to filter out photos that are only in All-Photos:

--query-eval "len(photo.albums) > 1 or 'All-Photos' not in photo.albums" --directory "{folder_album|remove(All-Photos)}"

This excludes (via --query-eval) any photo that is only in All-Photos. Photos in another album or photos not in any album will be included. The --directory template excludes the All-Photos folder for any photo that is in All-Photos but also in one or more other albums. You'll need to decide how to handle the photos not in any album using the template default as described above. Currently, they'll go to the default folder _.

@petebocken
Copy link

Ohhhh, I feel like such a dork. @oPromessa got it exactly. The photos that are not getting excluded and are getting exported are the ones that are not in the "All-Photos" album. So it's working exactly as expected. I just didn't know that is how it worked apparently!

Some context as to why do I have an "All-Photos" album with all my photos:
I use the iOS Featured Photos Widget on my home screen and I was sick of it surfacing the same photos over and over again. I was also sick of Apple's decision of what photos are "good enough" to show me.
So I thought what if I used the Album Photos Widget. Throw all my photos in an album and point the widget to it. Turns out it works great! I see more different photos!

I can try messing with these query-eval options, but I do have enough disk space on the drive I export to, so I could just leave my script alone and not try to exclude this and just essentially have duplicates of all photos (since I already have all photos organized into albums --- I maintain all photos in albums, no photo is not in an album).

So sorry for making you run in circles @RhetTbull! Guess we solved my issue! 😳

@RhetTbull
Copy link
Owner Author

No worries! If all photos are in more than one album and you want to exclude the duplicates from 'All-Photos' then dropping the query eval and using this should work: --directory "{folder_album|remove(All-Photos)}"

@petebocken
Copy link

No worries! If all photos are in more than one album and you want to exclude the duplicates from 'All-Photos' then dropping the query eval and using this should work: --directory "{folder_album|remove(All-Photos)}"

Works perfectly, thanks so much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Pertains to the command line interface feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants