It's important for these files to be exactly double- or half the size of their counterpart.
This script, if saved as a separate script, can do just that using hazel.

Further explanation: http://www.nimbling.com/blog/2012/02/automatic-flight-check-for-ios-retina-files/
*edit* you can download this script, as well as a single-file version here: http://www.nimbling.com/Downloads/Flight%20Check.zip
*edit2* I made a regular folder actions version of this, too!

Enjoy!
- Code: Select all
global x_factor, y_factor, labelfile
on hazelProcessFile(theFile)
tell application "Finder"
launch
tell application "System Events"
set PosPAth to POSIX path of theFile
set filename to name of (theFile as alias)
set labelfile to theFile as alias
end tell
set ParentFolder to container of theFile -- sets the parent folder of the folder you select
set ParentFoldertxt to ParentFolder as text
set filename to name of file theFile -- sets the folder name as text
set old_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
set checkFile to first text item of filename as text
set AppleScript's text item delimiters to old_delimiters
tell me to set {my_x, my_y} to getsize(theFile)
if checkFile contains "ipad" or checkFile contains "iPad" then
set statusmsg to "iPad Asset"
return statusmsg
else if checkFile contains "@2x" then
tell me to set filetwin to findAndReplace("@2x", "", checkFile) & ".png"
set filetwin to ParentFoldertxt & filetwin
if exists file filetwin then
tell me to set {other_x, other_y} to getsize(filetwin)
set x_factor to my_x / other_x
set y_factor to my_y / other_y
tell me to verifyTwinfactor(x_factor, y_factor, filetwin)
set statusmsg to "standard_twin_found"
else
set statusmsg to "no_standard_file"
set the label index of labelfile to 2 -- 2=RED
return statusmsg
end if
else
set filetwin to ParentFoldertxt & checkFile & "@2x.png"
if exists file filetwin then
tell me to set {other_x, other_y} to getsize(filetwin)
set x_factor to other_x / my_x
set y_factor to other_y / my_y
tell me to verifyTwinfactor(x_factor, y_factor, filetwin)
set statusmsg to "retina_twin_found"
else
set the label index of labelfile to 1 -- 1=ORANGE
set statusmsg to "no_retina_file"
return statusmsg
end if
end if
end tell
end hazelProcessFile
on verifyTwinfactor(x_factor, y_factor, filetwin)
tell application "Finder"
launch
if x_factor as real is 2.0 and y_factor as real is 2.0 then
tell application "Finder"
set the label index of labelfile to 6 -- 0=NONE 6=GREEN
set the label index of file filetwin to 6 -- 0=NONE 6=GREEN
end tell
set statusmsg to "twin_ok"
return statusmsg
else
tell application "Finder"
set the label index of labelfile to 5 -- PURPLE
end tell
set statusmsg to "twin_bad"
return statusmsg
end if
end tell
end verifyTwinfactor
on getsize(theFile)
tell application "Image Events"
launch
set my_image to open theFile
set my_dimensions to dimensions of my_image
close my_image
set my_x to item 1 of my_dimensions as integer
set my_y to item 2 of my_dimensions as integer
quit
return {my_x, my_y}
end tell
end getsize
on findAndReplace(tofind, toreplace, TheString)
set ditd to text item delimiters
set text item delimiters to tofind
set textItems to text items of TheString
set text item delimiters to toreplace
if (class of TheString is string) then
set res to textItems as string
else
set res to textItems as Unicode text
end if
set text item delimiters to ditd
return res
end findAndReplace