View unanswered posts | View active topics It is currently Wed May 22, 2013 7:36 am



Reply to topic  [ 2 posts ] 
 Find Most Recent Image in Folder 
Author Message
Online

Joined: Nov 26, 2009
Posts: 924
Location: Kalispell, MT
Post Find Most Recent Image in Folder
Hey,

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


Sat Jun 16, 2012 4:03 pm
Profile
Online

Joined: Nov 26, 2009
Posts: 924
Location: Kalispell, MT
Post Re: Find Most Recent Image in Folder
Doh,....yet again.

Just needed this bit of code:

tell application "Finder"
sort (get files of sourceFolder) by creation date
-- This raises an error if the folder doesn't contain any files
set theFile to (item 1 of result) as alias
end tell

The ability to take a picture, with any camera loaded with an Eye-Fi card, and have Indigo
display it on our always on display screen has proven to be one of the most popular functions
with all family members.

Thanks,

Carl


Mon Jun 18, 2012 5:08 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.