I'm setting up a folder action to process an incoming image, from an EyeFi card, to have displayed
on a control page. It works well except I need to modify it to locate the most recent image added
to the folder instead of the file name.
I got it working to process by the name ok but when using different cameras the numbering
is different which throws the script off, hence the need to process by most recent image added.
I think this is the line I can't seem to get right:
set theImage to first item of (every paragraph of (do shell script "ls -t " & EyeFiToProcessFolder)
- Code: Select all
on adding folder items to this_folder after receiving added_items
try
set EyeFiToProcessFolder to (path to desktop as text) & "EyeFi to Process:"
---set theOutputFolder to (path to desktop as text) & "EyeFi Images:1.jpg"
set theOutputFolder to "/Users/TV/Sites/1.jpg"
tell application "Finder"
---set theImage to last file of folder EyeFiToProcessFolder whose name starts with "D"
set theImage to first item of (every paragraph of (do shell script "ls -t " & EyeFiToProcessFolder))
end tell
tell application "Image Events"
launch
set theImageReference to open file (theImage as text)
tell theImageReference
scale it to size 700
save in theOutputFolder as JPEG
close
tell application "IndigoServer"
execute group "EyeFi on Display Screen"
end tell
end tell
end tell
set theFolder to (path to desktop as text) & "EyeFi to Process:"
set numberOfFiles to count of (paragraphs of (do shell script "mdfind -onlyin " & quoted form of POSIX path of theFolder & " kMDItemFSInvisible == 0"))
tell application "IndigoServer"
set the value of variable "EyeFi_Count" to numberOfFiles
end tell
end try
end adding folder items to
Any help greatly appreciated!
Thanks,
Carl