You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How do I sort videos by length of time or by file size?

Using Photos for Mac, how do I sort by the length of playing time or by how big the file is? I am looking to find the "big offender" in storage space and if they are 10 minutes of junk, I would like to delete them and reclaim some storage space.


Thanks

iMac, Mac OS X (10.6)

Posted on Sep 17, 2015 5:41 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 19, 2017 10:50 AM

If you select all videos in the Video album, you could run the script below. It will ask for a file size threshold - you could enter 512 kB, for example, then run the script. It will create two albums, one with the items smaller or equal than 512kB, one with the items larger than 512kB. now you can select easily the items that are too small or too large.



-- ✄ ✄ -- snip -- copy from here

(* How to use this script:


This script will split the selection into two albums -

- one album with pictures or videos larger than the given file size threshold

- one album with pictures or videos smaller than the given file size threshold


Open this script in Script Editor. Launch Photos.

Select the photos and videos you want to distribute between the albums.


When all all photo are selected, press the "Run" button in Script Editor.


Author: léonie

*)


--the file size threshold in kB

set defaultFileSizeThreshold to 10240 -- 10 MB, change this to the file size threshold you want for a photo to be counted as small


set dialogResult to display dialog ¬

"Enter the file size threshold for small photos or videos in kB : " buttons {"Cancel", "OK"} ¬


default answer (defaultFileSizeThreshold as text)

set FileSizeThresholdkB to (text returned of dialogResult) as integer-- file size in kB

set FileSizeThreshold to FileSizeThresholdkB * 1024 -- file size in Byte



set smallAlbumName to "smallerThan" & FileSizeThresholdkB-- the album to collect the small photos


set largeAlbumName to "largerThan" & FileSizeThresholdkB-- the album to collect the larger photos


tell application "Photos"


activate


-- Ensure that the albums do exist

try

set imageSel to (get selection)

on error errTexttwonumbererrNumtwo

display dialog "Cannot get the selection: " & errNumtwo & return & errTexttwo

end try


-- return the size of the first item of imageSel


try

if not (exists container smallAlbumName) then


makenewalbumnamedsmallAlbumName

end if

set theSmallAlbum to containersmallAlbumName


if not (exists container largeAlbumName) then


makenewalbumnamedlargeAlbumName

end if

set theLargeAlbum to containerlargeAlbumName


if not (exists container "SkippedPhotos") then

make new album named "SkippedPhotos"

end if

set theSkippedAlbum to container "SkippedPhotos"



on error errTexttwonumbererrNumtwo

display dialog "Cannot open albums: " & errNumtwo & return & errTexttwo

end try



-- process the selected photos from the All Photos album


set smallPhotos to {} -- the list of small photos

set largePhotos to {} -- the list of larger photos

set skippedPhotos to {} -- the list of skipped photos




-- check, if the album or the selected photos do contain images


if imageSel is {} then

error "Please select some images."

else

repeat with im in imageSel

try


tell im--get the file size

set s to its size

end tell

on error errText number errNum

display dialog "Error: " & errNum & return & errText & "Trying again"

try

delay 2

tell im

set s to its size


end tell

on error errTexttwonumbererrNumtwo

display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo

end try


end try

set noSize to (s is missing value)

if noSize then

set skippedPhotos to {im} & skippedPhotos

else

if (sFileSizeThreshold) then

set smallPhotos to {im} & smallPhotos

else

set largePhotos to {im} & largePhotos


end if

end if


end repeat



addsmallPhotostotheSmallAlbum


addlargePhotostotheLargeAlbum


addskippedPhotostotheSkippedAlbum


return "small photos: " & (length of smallPhotos) & ", larger photos : " & (length of largePhotos) & ", skipped: " & (length of skippedPhotos)


end if


end tell

11 replies
Question marked as Top-ranking reply

Oct 19, 2017 10:50 AM in response to craig4569

If you select all videos in the Video album, you could run the script below. It will ask for a file size threshold - you could enter 512 kB, for example, then run the script. It will create two albums, one with the items smaller or equal than 512kB, one with the items larger than 512kB. now you can select easily the items that are too small or too large.



-- ✄ ✄ -- snip -- copy from here

(* How to use this script:


This script will split the selection into two albums -

- one album with pictures or videos larger than the given file size threshold

- one album with pictures or videos smaller than the given file size threshold


Open this script in Script Editor. Launch Photos.

Select the photos and videos you want to distribute between the albums.


When all all photo are selected, press the "Run" button in Script Editor.


Author: léonie

*)


--the file size threshold in kB

set defaultFileSizeThreshold to 10240 -- 10 MB, change this to the file size threshold you want for a photo to be counted as small


set dialogResult to display dialog ¬

"Enter the file size threshold for small photos or videos in kB : " buttons {"Cancel", "OK"} ¬


default answer (defaultFileSizeThreshold as text)

set FileSizeThresholdkB to (text returned of dialogResult) as integer-- file size in kB

set FileSizeThreshold to FileSizeThresholdkB * 1024 -- file size in Byte



set smallAlbumName to "smallerThan" & FileSizeThresholdkB-- the album to collect the small photos


set largeAlbumName to "largerThan" & FileSizeThresholdkB-- the album to collect the larger photos


tell application "Photos"


activate


-- Ensure that the albums do exist

try

set imageSel to (get selection)

on error errTexttwonumbererrNumtwo

display dialog "Cannot get the selection: " & errNumtwo & return & errTexttwo

end try


-- return the size of the first item of imageSel


try

if not (exists container smallAlbumName) then


makenewalbumnamedsmallAlbumName

end if

set theSmallAlbum to containersmallAlbumName


if not (exists container largeAlbumName) then


makenewalbumnamedlargeAlbumName

end if

set theLargeAlbum to containerlargeAlbumName


if not (exists container "SkippedPhotos") then

make new album named "SkippedPhotos"

end if

set theSkippedAlbum to container "SkippedPhotos"



on error errTexttwonumbererrNumtwo

display dialog "Cannot open albums: " & errNumtwo & return & errTexttwo

end try



-- process the selected photos from the All Photos album


set smallPhotos to {} -- the list of small photos

set largePhotos to {} -- the list of larger photos

set skippedPhotos to {} -- the list of skipped photos




-- check, if the album or the selected photos do contain images


if imageSel is {} then

error "Please select some images."

else

repeat with im in imageSel

try


tell im--get the file size

set s to its size

end tell

on error errText number errNum

display dialog "Error: " & errNum & return & errText & "Trying again"

try

delay 2

tell im

set s to its size


end tell

on error errTexttwonumbererrNumtwo

display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo

end try


end try

set noSize to (s is missing value)

if noSize then

set skippedPhotos to {im} & skippedPhotos

else

if (sFileSizeThreshold) then

set smallPhotos to {im} & smallPhotos

else

set largePhotos to {im} & largePhotos


end if

end if


end repeat



addsmallPhotostotheSmallAlbum


addlargePhotostotheLargeAlbum


addskippedPhotostotheSkippedAlbum


return "small photos: " & (length of smallPhotos) & ", larger photos : " & (length of largePhotos) & ", skipped: " & (length of skippedPhotos)


end if


end tell

Oct 19, 2017 8:03 AM in response to craig4569

I meant just to export the videos to a folder in the Finder to get a sorted list, but not to delete them from Photos.


It might be easier to find the large video files and to remove them quickly, if you download the free trial version of PowerPhotos. You can download it here: (https://www.fatcatsoftware.com/powerphotos/)


PowerPhotos will open a second browser for your Photos Library. You can display the items in your library in list view with many metadata and sort by each column by clicking the column header, i.e. by the file size. You can then select the top candidates in the file size column, ctrl click each large video in turn and use the command "Show in Photos" and then remove it from Photos.


My list of videos in PowerPhotos looks like this:

User uploaded file


Launching PowerPhotos is. bait slow for a large library, but I simply keep it open all day, in case I should need it as a second window for my Photos Library.

Oct 19, 2017 8:33 AM in response to léonie

Hi thanks



I had a look at power photos I would still have to go into the photos app and find the offenders and delete them im looking for all the small files unlike the poster all the 0.01 and 0.02 files that have creeped in over the years there is now way to delete them using PowerPhotos and they are spread all over the 3849 videos I have in my database


I just need to be able to list them within the photos app in time order so we can review the large files and delete the small 0.01 second files as they go up automatically to iCloud one little double tap and we have lots of these little mistakes everywhere

Oct 19, 2017 10:34 AM in response to craig4569

I had a look at power photos I would still have to go into the photos app and find the offenders


But PowerPhotos will reveal the photo in Photos if you control-click it. It will take you right to the photo in Photos in the Moments so you can delete it there.


The programming interface of Photos does not allow other applications to delete photos from Photos. Therefore, there is no application that is safe to use to delete photos or videos directly from a Photos Library.

You could write an AppleScript to collect all smaller items in an album and the delete the photos in this album from the library.

An AppleScript can read the file size of a media item in Photos.

How do I sort videos by length of time or by file size?

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