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
    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
        end tell
        activate
        display alert "New Items Added!" message ("File called " & FileName & " have been added" as string)
    end repeat
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
  • If multiple files get added to the folder at the same time... Because of the added loop function... An alert should be displayed for each file added. – wch1zpink Oct 4 '18 at 18:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.