1

This is mostly a test so that I can work up to the function that I want to create down the line. I'm very new to AppleScript so bear with me!

I wrote this as an attempt to test a folder action that receives a new file and then displays an alert with the name of the newly added file.

This Script was saved to ~/Library/Scripts/Folder Action Scripts. And then assigned to a folder on my desktop called Return Name. I see the script run when a new item is dropped in but nothing happens.

Can anyone just explain to me what is wrong here?

Thanks!

on adding folder items to InputFolder after receiving NewItem
tell application "Finder"
    set FileName to name of NewItem
    activate
    display alert "New Items Added!" message ("File called " & FileName & " have been added" as string)
end tell
end adding folder items to
1

This should work for you

on adding folder items to theFolder after receiving theNewItems
    delay 20 -- ALLOW MULTIPLES TO BE ADDED BEFORE PROCESSING - OPTIONAL
    set filesAdded to {}
    tell application "Finder" to set folderName to name of folder theFolder
    repeat with i from 1 to count of theNewItems
        set thisItem to item i of theNewItems
        tell application "Finder"
            set FileName to name of thisItem
            set end of filesAdded to (FileName & linefeed)
        end tell
    end repeat
    activate
    display alert "New Items Added!" message (("These Files Have Been Added To " & theFolder) & linefeed & linefeed & filesAdded as string)
end adding folder items to
  • Thanks! So is the loop portion that you added required for such functions? – branarama Oct 4 '18 at 18:52
  • I don't think you need the delay. Yes, you can get multiple items at once. – historystamp Feb 16 at 0:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .