iCloud Photos: Albums missing from folders, found via search

At some point in time recently, an iCloud photos sync has managed to lose one or more of my 'folders' that I use to organise albums in my photos library.


The consequence of this is that the albums within that folder are now not accessible from the albums browser on the left.


However, if I search for them, they appear in the 'Collections' search results. It's only the fact that I know I had a folder named 'birthdays' that is now missing, and if i search for the keyword birthday, then I get 67 albums returned in the search, that otherwise are not accessible from the album browser .


How many other albums are orphaned like this, I don't know - and I would only know if I remember the names of the albums...😡


I have a time machine backup for the last 6 months - but the library is so big (over 1 TB)... that it fails every time it restores, so I can't even restore it making the Time Machine backup useless.


If I could drag and drop the albums I've found from search, that would help - as I could create a new folder - but you cannot drag and drop albums from search results in photos app.


Posted on Jan 4, 2026 12:56 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 4, 2026 6:16 AM

Ok, I've spent the afternoon figuring this out, as it's important to me. I'll explain how I've fixed it - but beware, I'm a software developer so this is arguably easier for me to understand than if you have no knowledge of how these things work.


The solution is:


Photos library is backed by an sqlite database, which you definitely should NOT modify if you don't know what you're doing - and if you do know what you're doing, make a backup of it first. You can get to it by right clicking your .photoslibrary file and 'show package contents'. It's in the database folder and it's called Photos.sqlite.


I edited it with a free app called DB Browser for SQLite. First close your Photos app.


The problem I had remember was missing top level folders. All albums and folders are listed in a database tabled called ZGENERICALBUM. Albums and folders are differentiated by the ZKIND column.


You can find trashed folder with this SQL:


SELECT Z_PK, ZTITLE, ZTRASHEDDATE

  FROM ZGENERICALBUM

  WHERE ZTRASHEDSTATE = 1

    AND ZKIND = 4000

  ORDER BY ZTRASHEDDATE;


If you execute this, you will see all the folders that have been trashed. You can untrash them by executing this SQL:


UPDATE ZGENERICALBUM

  SET ZTRASHEDSTATE = 0,

      ZTRASHEDDATE = NULL

  WHERE ZTRASHEDSTATE = 1

    AND ZKIND = 4000;



I then closed the DB Browser app and opened Photos again. These changes alone made the missing folders appear again in my Photos library, and the albums were inside the folders as they should be. 👍


However they didn't sync to iCloud straight away. I had to rename each folder in the Photos app, just a little change to the name, which triggered them to rsync to iCloud.


This fixed it completely.


This certainly could be scripted or added to an app such as 'power photos' to make it easier for the layperson to fix their library.


Good luck.


By the way. To help me understand the sqlite database structure, I first dumped the whole database and contents to a text file, using sqlite3 on the command line (install this with brew). I then use Claude Code to inspect this text file, giving it examples of the folders that were missing and those that were ok, and getting it to compare and tell me the difference and the structure of the data. I then asked Claude to generate the SQL statements for me.


4 replies
Question marked as Top-ranking reply

Jan 4, 2026 6:16 AM in response to bandejapaisa

Ok, I've spent the afternoon figuring this out, as it's important to me. I'll explain how I've fixed it - but beware, I'm a software developer so this is arguably easier for me to understand than if you have no knowledge of how these things work.


The solution is:


Photos library is backed by an sqlite database, which you definitely should NOT modify if you don't know what you're doing - and if you do know what you're doing, make a backup of it first. You can get to it by right clicking your .photoslibrary file and 'show package contents'. It's in the database folder and it's called Photos.sqlite.


I edited it with a free app called DB Browser for SQLite. First close your Photos app.


The problem I had remember was missing top level folders. All albums and folders are listed in a database tabled called ZGENERICALBUM. Albums and folders are differentiated by the ZKIND column.


You can find trashed folder with this SQL:


SELECT Z_PK, ZTITLE, ZTRASHEDDATE

  FROM ZGENERICALBUM

  WHERE ZTRASHEDSTATE = 1

    AND ZKIND = 4000

  ORDER BY ZTRASHEDDATE;


If you execute this, you will see all the folders that have been trashed. You can untrash them by executing this SQL:


UPDATE ZGENERICALBUM

  SET ZTRASHEDSTATE = 0,

      ZTRASHEDDATE = NULL

  WHERE ZTRASHEDSTATE = 1

    AND ZKIND = 4000;



I then closed the DB Browser app and opened Photos again. These changes alone made the missing folders appear again in my Photos library, and the albums were inside the folders as they should be. 👍


However they didn't sync to iCloud straight away. I had to rename each folder in the Photos app, just a little change to the name, which triggered them to rsync to iCloud.


This fixed it completely.


This certainly could be scripted or added to an app such as 'power photos' to make it easier for the layperson to fix their library.


Good luck.


By the way. To help me understand the sqlite database structure, I first dumped the whole database and contents to a text file, using sqlite3 on the command line (install this with brew). I then use Claude Code to inspect this text file, giving it examples of the folders that were missing and those that were ok, and getting it to compare and tell me the difference and the structure of the data. I then asked Claude to generate the SQL statements for me.


Jan 4, 2026 7:48 AM in response to bandejapaisa

Whether you comfortable with sqlite database programming or not, you should only mess with the Photos Database on a copy, if you value your picture data.


When you delete an album, the pictures "inside" remain in the Library. Unlike that, when you delete a Folder, the "contained" albums are deleted as well. The best remedy for mistakenly deleting folders is having a backup of the Library.

Jan 4, 2026 11:23 AM in response to Richard.Taylor

Thanks for your response, but it's almost like you didn't really read any of it properly.


Firstly I did say in my response, to make a backup copy first - which I did - and I tested on first. So yes, I do value my photo data, which is why this was necessary to do this fix, as I had orphaned albums that I couldn't access.


The original problem was not because I deleted a folder - I'd be aware if I did that. You get confirmation warnings when you delete items - and there were 10 deleted folders - and the albums were NOT deleted, they were somehow orphaned from their parent folder and not accessible.


And yes... a backup of the library is probably the best remedy - but I also stated my time machine backup kept failing to recover.


Despite your best advice - by modifying my Photos.sqlite database, I fixed the problem.





iCloud Photos: Albums missing from folders, found via search

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.