How to sort Apple Live Photos when your photo software doesn't recognise them

Posted by Howard Richardson (comments: 0)

Apple Live Photos record a short 2-3 second video clip along with every photo you take. They're nice to have sometimes as they provide a little context for the accompanying photo. However after having sorted all your photos out nicely into folders and deleted the ones you didn't want from within your photo management software, you're sometimes left with many Live Photo .MOV files over that don't belong to a photo any more.

What I needed was a simple way to make sure photos and Live Photos stay paired, and be able to find Live Photos which have become orphaned when their matching real photo was deleted.

I wrote a small command line script to sort this. It checks for every MOV file to see if it has a matching JPG with the same filename. If not, it makes a guess at if the MOV is a real movie or an orphaned Live Photo. In the absence of any obvious way to tell these two apart, I decided length of the video was as good a determining factor as any. So the script checks the number of frames the video has and if it's less than 80 (or whatever you set it to) then it treats the MOV like it is a Live Photo.

Practically now, I can just open a shell in any directory full of mixed JPGs and MOVs, run this script there, and it will sort out any orphaned Live Photos into a subdirectory called "orphans". From there I can choose to either delete or keep them.

Here's the little script I wrote. It depends on the command-line tool mediainfo for detecting how many frames each MOV file has too, so make sure you have that installed first.

#!/bin/bash
# Sort out orphaned Apple Live-Photos

# Set this at max number of frames for a Live Photo
threshold_frames=80;

mkdir -p "orphans"
for a in *.MOV
do 
	if [ ! -f "${a%.MOV}.JPG" ]; then
	   framecount=`mediainfo "$a" --inform="General;%FrameCount%"`
	   if [ $framecount -lt $threshold_frames ] ; then 
	   	echo "Orphaned Live Photo: $a"
	   	mv "$a" "orphans/"
	   fi
	fi
done

Go back

Add a comment