Indem Du ein anderes Skript aus derselben Quelle verwendest:
https://discussions.apple.com/docs/DOC-12211
Show Plain Text
- (*
- https://discussions.apple.com/docs/DOC-12211
- The Photos.app does not allow us to sort albums by the file size of the items ins an album. But an AppleScript can read the file size of a media item in Photos and create albums based on the file size.
- If you want to find files, that are too large or to small among a set of media items in Photos, select the videos or photos you want to check for their size and 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 in one of the albums.
- 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 errTexttwo number errNumtwo
- 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
- make new album named smallAlbumName
- end if
- set theSmallAlbum to container smallAlbumName
- if not (exists container largeAlbumName) then
- make new album named largeAlbumName
- end if
- set theLargeAlbum to container largeAlbumName
- if not (exists container "SkippedPhotos") then
- make new album named "SkippedPhotos"
- end if
- set theSkippedAlbum to container "SkippedPhotos"
- on error errTexttwo number errNumtwo
- 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 errTexttwo number errNumtwo
- 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 (s ≤ FileSizeThreshold) then
- set smallPhotos to {im} & smallPhotos
- else
- set largePhotos to {im} & largePhotos
- end if
- end if
- end repeat
- add smallPhotos to theSmallAlbum
- add largePhotos to theLargeAlbum
- add skippedPhotos to theSkippedAlbum
- return "small photos: " & (length of smallPhotos) & ", larger photos : " & (length of largePhotos) & ", skipped: " & (length of skippedPhotos)
- end if
- end tell
- (*
- This user tip was generated from the following discussion: How do I sort videos by length of time or by file size?
- https://discussions.apple.com/thread/7220031
- *)