Simple code needed and I can't figure it out

  • Posted: 11 September 2007 03:26 PM

    I’ve got an applescript that runs as a Folder Action.  It needs to test the files with an “If statement” so that it only runs on certain files.

    on adding folder items to this_folder after receiving added_items
        
        
    Here
    's the problem: ---> if added_items are (*.pdf files) then
                    
            (*
    tell application "Terminal"
                do script "bla bla bla; exit"
            end tell
    *)
            
            
        end if
    end adding folder items to 

    I just don’t know the proper syntax to tell the script to only run if the file is a .pdf file.

    Any help would be greatly appreciated.

    Thanks!

         
  • Avatar

    Posted: 11 September 2007 07:07 PM #1

    I suggest the script should start like this:

    on adding folder items to this_folder after receiving added_items 

    repeat with added_file in added_items
            set fileName to name of added_file
            
    if fileName ends with ".pdf" then 

    And continue on from there.  I think that should work based on some things I found around the internet, but I generally don’t use AppleScript and haven’t tested it.  I am, however, a software engineer professionally, so I’m making an educated guess.

    Good luck.  smile

    Signature

    According to statistics, half the world is below average intelligence
    "The power of accurate observation is commonly called cynicism by those who have not got it."-George Bernard Shaw
    "You can’t change that by gettin’ all…bendy."

         
  • Posted: 13 September 2007 07:02 PM #2

    That doesn’t work

    Thank you but, I tried that and all sorts of variations and can’t get any of them to work.

    Anyone have any other suggestions?