This was not uncomplicated, but I managed to successfully restore the live photos. Here's how.
Step 1: Confirm .MOV
files still exist
Export your library like so:
- Open Photos app, select 'Library' on left hand side
- Click on one photo or video
- command + a to select all
- File -> Export -> Export unmodified originals
Locate an image (.JPG
) file that should be a live photo
cd
into the photoslibrary directory, and run this (replace IMG_3959
with the name of the image you found above)
find . -type f -name "*IMG_3959*"
./Resources/modelresources/65/103/AgvQKkqoTfm3nFEa3w3A%A/IMG_3959.MOV
Notice that it finds a corresponding .MOV
file! So I ran:
open ./Resources/modelresources/65/103/AgvQKkqoTfm3nFEa3w3A%A/IMG_3959.MOV
And it plays a 3 second video! I repeated this a bunch of times for a few images to confirm that the .MOV
files for the broken live photos do in fact exist!
Step 2: Move lost .MOV
files into one place
Get a list of the library's live photos. Download osxphotos, place the binary in /usr/local/bin
, open a new terminal, and run:
osxphotos query --live --query-eval "not photo.path_live_photo" --field uuid "{uuid}" --field filename "{photo.original_filename}" --field path "{photo.path}" --library /path/to/your/photos/library > live-photos.csv
Then this will go through each live photo and look for the corresponding .MOV
file and list its location in a new file called videos.csv
#!/bin/sh
# Define the input and output CSV files
input_csv="live-photos.csv"
output_csv="videos.csv"
# Create or clear the output CSV file and write the header
echo "image,video" > "$output_csv"
# Use a temporary file to avoid a pipeline with a loop
temp_file=$(mktemp)
tail -n +2 "$input_csv" > "$temp_file"
# Read from the temporary file
while IFS=, read -r uuid filename path
do
# Use find to search for a matching .MOV file
mov_file=$(find . -type f -iname "${filename%.*}*.MOV" -print -quit)
# If a .MOV file is found, write the image filename and MOV path to the output CSV
if [[ -n "$mov_file" ]]; then
echo "${filename},${mov_file}" >> "$output_csv"
fi
done < "$temp_file"
# Clean up temporary file
rm "$temp_file"
Here's mine:
Now move these .MOV
files into one place
#!/bin/bash
# Create the directory if it doesn't already exist
mkdir -p mov-files
# Read each line from the CSV file starting from the second line
while IFS=',' read -r image video
do
# Copy the .MOV file to the mov-files directory
cp "$video" mov-files/
done < <(tail -n +2 videos.csv)
Step 3: Make a new photo library with working live photos
Create a new directory with all the exported unmodified originals from the first step. To that directory, copy all the missing .MOV
files found above.
Close Photos app. Hold option and click on the Photos app in dock to open it. Click on 'Create new'. Click File -> Import -> select the directory with your unmodified originals + .MOV
files.
Live photos should now work!