please help me in applescript

Discussion in 'Mac Programming' started by Reference, Jan 2, 2007.

  1. macrumors newbie

    Jan 2, 2007
    hi out there!

    i´m new here und a real big dummy in puncto programming. now i have a special interest: finder-based i would read out the filenames of an defined folder (in my case only files with the ending .pdf", copy them and insert the file names in my standard mail program "mail".

    hmm sounds so easy, but isn´t it for me ;)
    for help of you specialists out there in the world i would be very happy. thank you so much.
  2. macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    What code have you got down so far? It is hard to help without seeing how far you have got :).
  3. thread starter macrumors newbie

    Jan 2, 2007
    my code looks like this:

    tell application "Finder"
    mount volume "afp://xxxxx/xxxx" as user name "xxxxx" with password "xxxxxxx"
    end try
    set theFolder to alias "xxxxxx:xxxxxxx:"
    set fileList to (get every file of theFolder whose name ends with "pdf")
    repeat with i from 1 to (count fileList)
    set str to (name of item i of fileList)
    display dialog str
    end repeat
    end tell

    tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:"xxxxxxxxxx"}
    tell newMessage
    set visible to true
    set sender to "Absender <xxxxx@xxxxxx>"
    make new to recipient at end of to recipients with properties {address:"xxxxxxx@xxxxxxxxx,xxxxxxxxxx@xxxxxxxxx"}
    end tell
    end tell

    the part setfilelist is just a try for me. how do i get the names of my target files in the body of the new mail? thanks
  4. macrumors G4


    Nov 3, 2005
    You can add attachments to an email with Automator, whether it can also be done in Applescript I don't know but it's likely. though you can also add applescript to an automator widget, maybe that's an easier way to go about it. There is more info on this here.
  5. macrumors 68040


    Sep 13, 2003
    Its not so much where you are as when you are.
    Set content to filelist

    One other thing to do is up at the top

    tell application "Finder" to set fileList to (name of every file of theFolder whose name ends with "pdf")
    set applescript's text item delimiters to ", "
    set fileList to ""&fileList
    set applescript's text item delimiters to {""}

Share This Page