Resolved Camera Roll Out of Order FIX/tutorial

Mr_Brightside_@

macrumors 68040
Original poster
Sep 23, 2005
3,384
1,441
Toronto
0)
Back up your phone and place it in Airplane mode (DigiDNA's suggestion)


1)
Make sure Photos is running on your iPhone
Download iMazing or similar
Connect iPhone to Mac via USB
In the sidebar select your phone
Click File System > Media > PhotoData
Select Photos.sqlite and Copy to Mac at bottom
Find the file you've just copied
First, make a copy of it in a separate location in case of emergency

2)
Open Terminal
At the prompt type
$ sqlite3
You should see your SQLite version listed
Type .open at the sqlite> prompt, then drag the Photos.sqlite file from Finder to the sqlite> prompt, then hit Enter:
sqlite> .open /Users/yourname/Desktop/Photos.sqlite
To test that you've opened the file properly, type .tables and hit enter. You should see a list of files starting with Z, which is what you want.
At the prompt again, paste in:
UPDATE zgenericasset SET zaddeddate = zdatecreated WHERE zaddeddate>0 AND zdirectory LIKE 'DCIM%';
Hit enter. There should be a slight, 1 second delay before you see the sqlite> prompt again. This means the query is working, which is good. You should also see the Modified date for the sqlite file change in Finder
Finally, type .save Photos.sqlite and hit Enter (not actually sure if this is necessary or does anything, but I did it when I was successful)
Quit Terminal, clicking Close on the warning window

3)
Go back to iMazing into the PhotoData folder
I made a 'backup' of the existing Photos.sqlite by renaming it to oldPhotos.sqlite
Copy over the modified Photos.sqlite from your Mac
Quit iMazing
Force quit the Photos app
Reopen Photos
Hopefully, your photos will be in order!

Let me know if this works for you!

UPDATE 31 DEC:

I noticed in Moments (Photos tab at left) that most of the thumbnails were incorrect. I force quit Photos, then again using iExplorer, I navigated to \PhotoData\Thumbnails\ and backed up, then deleted all ithmb files. All seems to be good now. Not sure if this is related but thinking it is!

Another annoying oddity: I've found the Photos search feature isn't properly indexed. If I search for a category or location (say, Dog) I get far fewer results than I used to (before applying the fix I think).



Does anyone have any insight on where this might be located?
 
Last edited:
  • Like
Reactions: asv56kx3088

nginok

macrumors newbie
Dec 7, 2017
1
0
Thanks! it works!!

0)
Back up your phone and place it in Airplane mode (DigiDNA's suggestion)


1)
Make sure Photos is running on your iPhone
Download iMazing or similar
Connect iPhone to Mac via USB
In the sidebar select your phone
Click File System > Media > PhotoData
Select Photos.sqlite and Copy to Mac at bottom
Find the file you've just copied
First, make a copy of it in a separate location in case of emergency

2)
Open Terminal
At the prompt type
$ sqlite3
You should see your SQLite version listed
Type .open at the sqlite> prompt, then drag the Photos.sqlite file from Finder to the sqlite> prompt, then hit Enter:
sqlite> .open /Users/yourname/Desktop/Photos.sqlite
To test that you've opened the file properly, type .tables and hit enter. You should see a list of files starting with Z, which is what you want.
At the prompt again, paste in:
UPDATE zgenericasset SET zaddeddate = zdatecreated WHERE zaddeddate>0 AND zdirectory LIKE 'DCIM%';
Hit enter. There should be a slight, 1 second delay before you see the sqlite> prompt again. This means the query is working, which is good. You should also see the Modified date for the sqlite file change in Finder
Finally, type .save Photos.sqlite and hit Enter (not actually sure if this is necessary or does anything, but I did it when I was successful)
Quit Terminal, clicking Close on the warning window

3)
Go back to iMazing into the PhotoData folder
I made a 'backup' of the existing Photos.sqlite by renaming it to oldPhotos.sqlite
Copy over the modified Photos.sqlite from your Mac
Quit iMazing
Force quit the Photos app
Reopen Photos
Hopefully, your photos will be in order!

Let me know if this works for you!
 

mustafahussain17

macrumors newbie
Jan 8, 2018
1
0
Screen Shot 2018-01-08 at 22.48.35.png
Can someone please help? I really need my camera roll in order but everytime I do this I get the error above saying there is no such module...Thanks!
 

doubletap

macrumors regular
Jan 2, 2009
166
44
Ashburn, VA
I've also read that if you use iCloud Photos, you need to remove the directory and DCIM portion of this step:

UPDATE zgenericasset SET zaddeddate = zdatecreated WHERE zaddeddate>0 AND zdirectory LIKE 'DCIM%';

so it reads:

UPDATE zgenericasset SET zaddeddate = zdatecreated WHERE zaddeddate>0;

I use iCloud Photos and used the modified command without issue fwiw.
 

Mr_Brightside_@

macrumors 68040
Original poster
Sep 23, 2005
3,384
1,441
Toronto
This sounds correct - someone commented the same on Apple forums. Thanks for sharing it here!
[doublepost=1515511019][/doublepost]I've found the Photos search feature isn't properly indexed. If I search for a category or location (say, Dog) I get far fewer results than I used to (before applying the fix I think).



Does anyone have any insight on where this might be located?
 

Mr_Brightside_@

macrumors 68040
Original poster
Sep 23, 2005
3,384
1,441
Toronto
Update re iOS Photos app search being broken: deleting the Photos.sqlite file also seems to re-index the search function. Search categories and dates are now appearing properly. Note also that you may need to sync with a computer.
 
  • Like
Reactions: doubletap

sukimu

macrumors newbie
Sep 23, 2018
1
0
0)
Back up your phone and place it in Airplane mode (DigiDNA's suggestion)


1)
Make sure Photos is running on your iPhone
Download iMazing or similar
Connect iPhone to Mac via USB
In the sidebar select your phone
Click File System > Media > PhotoData
Select Photos.sqlite and Copy to Mac at bottom
Find the file you've just copied
First, make a copy of it in a separate location in case of emergency

2)
Open Terminal
At the prompt type
$ sqlite3
You should see your SQLite version listed
Type .open at the sqlite> prompt, then drag the Photos.sqlite file from Finder to the sqlite> prompt, then hit Enter:
sqlite> .open /Users/yourname/Desktop/Photos.sqlite
To test that you've opened the file properly, type .tables and hit enter. You should see a list of files starting with Z, which is what you want.
At the prompt again, paste in:
UPDATE zgenericasset SET zaddeddate = zdatecreated WHERE zaddeddate>0 AND zdirectory LIKE 'DCIM%';
Hit enter. There should be a slight, 1 second delay before you see the sqlite> prompt again. This means the query is working, which is good. You should also see the Modified date for the sqlite file change in Finder
Finally, type .save Photos.sqlite and hit Enter (not actually sure if this is necessary or does anything, but I did it when I was successful)
Quit Terminal, clicking Close on the warning window

3)
Go back to iMazing into the PhotoData folder
I made a 'backup' of the existing Photos.sqlite by renaming it to oldPhotos.sqlite
Copy over the modified Photos.sqlite from your Mac
Quit iMazing
Force quit the Photos app
Reopen Photos
Hopefully, your photos will be in order!

Let me know if this works for you!

UPDATE 31 DEC:

I noticed in Moments (Photos tab at left) that most of the thumbnails were incorrect. I force quit Photos, then again using iExplorer, I navigated to \PhotoData\Thumbnails\ and backed up, then deleted all ithmb files. All seems to be good now. Not sure if this is related but thinking it is!

Another annoying oddity: I've found the Photos search feature isn't properly indexed. If I search for a category or location (say, Dog) I get far fewer results than I used to (before applying the fix I think).



Does anyone have any insight on where this might be located?







I followed this tutorial to the letter, however when i move back the modified Photos.sqlite my entire library disappears and starts rebuilding from 0. When it is done the photos are still out of order.
Can you please help????
 

Mr_Brightside_@

macrumors 68040
Original poster
Sep 23, 2005
3,384
1,441
Toronto
That sounds like the database wasn't modified. Does the modified date update in Finder?

Do you have iCloud Photo Library enabled?
 

lordofthegins

macrumors member
Sep 17, 2018
45
47
Hawke's Bay, New Zealand
Hey all. After heaps of research, i've finally found this post!

I have iCloud Photo Library setup, so as long as I follow the above steps (with DoubleTaps) edits, this won't affect my iCloud library at all?
 

lordofthegins

macrumors member
Sep 17, 2018
45
47
Hawke's Bay, New Zealand
That sounds like the database wasn't modified. Does the modified date update in Finder?

Do you have iCloud Photo Library enabled?

Getting the same thing. Modified date in finder updates to when its saved.
When I modify the photos.sqlite file in iMazing, I notice there's two other files that are created:
photos.sqlite-wal and photos.sqlite-sh

Anyone know what those are?

Completed the tutorial with DoubleTaps iCloud photo edit, but the library is rebuilding from zero, with dates still out of sync
[doublepost=1555455066][/doublepost]
I followed this tutorial to the letter, however when i move back the modified Photos.sqlite my entire library disappears and starts rebuilding from 0. When it is done the photos are still out of order.
Can you please help????

Did you manage to resolve this?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.