1

How do I find out programmatically where the Photos app stores all the pictures?

Before answering that it's always

~/Pictures/Photos Library.photoslibrary/

, please be aware that this is only true for English installations of Mac OS. For example, in French, the folder is called

~/Pictures/Phototèque.photoslibrary/

and in German,

~/Pictures/Fotos-Mediathek.photoslibrary/
1

It's not as simple as changing the path based on the locale. The Photos library could be renamed and moved anywhere. You can find the current library by extracting the IPXDefaultLibraryURLBookmark from the Photos plist.

/usr/libexec/PlistBuddy -c "print IPXDefaultLibraryURLBookmark" \
~/Library/Containers/com.apple.Photos/Data/Library/Preferences/com.apple.Photos.plist

The IPXDefaultLibraryURLBookmark contains a CFURLRef. This will require deserialising.

  • Ew, that is ugly. But I guess it is the correct solution. – ThomasR Dec 28 '16 at 14:53
  • @Thomas No, defaults returns hex encoded data rather than decoding what it can to readable text. – grg Dec 28 '16 at 14:57
  • This is the only correct answer. Since it can be anywhere, the only correct way to know the location is to read where Photos itself thinks it is. – John Keates Dec 28 '16 at 16:16
0

Programatically, you would need to trace the app while it runs:

sudo fs_usage -w Photos

Except, that Photos uses some system daemons to update things in the background if you use iCloud backed libraries. What are you actually trying to do - learn how localized folder names work or how localization works in an app that's been internationalized with strings?

0

The folder name is composed of ~/Pictures/${localpart}.photoslibrary/, where ${localpart} stored in a .strings file provided by the Photos app. To extract it, use this command:

plutil -p /Applications/Photos.app/Contents/Resources/${lan}.lproj/IPXMain.strings |
  grep "IPXDefaultLibraryName" |
  cut -d">" -f2 | xargs

where ${lan} is your operation system's language. The latter can be detected using

defaults read .GlobalPreferences AppleLanguages |
  egrep -o "\w+"

Here is a list of possible localpart values:

ar  مكتبة الصور
ca  Fototeca de Fotos
cs  Knihovna fotografií
da  Fotobibliotek
de  Fotos-Mediathek
el  Βιβλιοθήκη φωτογραφιών
en  Photos Library
es  Fototeca de Fotos
es_MX  Fototeca de Fotos
fi  Kuvakirjasto
fr  Photothèque
he  ספריית תמונות
hr  Foto medijateka
hu  Fotókönyvtár
id  Perpustakaan Foto
it  Libreria di Foto
ja  写真ライブラリ
ko  [sorry, SE won't let me post Korean, which it detects as spam]
ms  Pustaka Foto
nl  Foto's-bibliotheek
no  Bilder-bibliotek
pl  Biblioteka Zdjęć
pt  Fototeca
pt_PT  Fototeca
ro  Bibliotecă Poze
ru  Медиатека Фото
sk  Knižnica aplikácie Fotky
sv  Bilder-bibliotek
th  คลังรูปภาพ
tr  Fotoğraflar Arşivi
uk  Медіатека програми «Фотографії»
vi  Thư viện Ảnh
zh_CN  照片图库
zh_TW  照片圖庫
  • Be careful using this to find an actual photo library. My photo library isn't in this location, so this would fail on my system. – grg Dec 28 '16 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .