0

I try to implement a folder action with Automator. So i use the module "folder action" and there defining the folder. The only action module in there is "Execute AppleScript" with this code inside:

on run {input, parameters}
    set fileName to name of (item 1 of input)
    display dialog fileName
end run

I simply want to know, if the file dropped into the folder will be transfered!

No dialog is showing up!

The workflow is connected to the folder, because when i insert an action module like "Delete file" it works!

Is there a permission problem?


I tried now the following (without Automator):

on adding folder items to this_folder after receiving these_items
        display dialog (item 1 of these_items) as text
  end adding folder items to

This works fine and shows me that the binding to my folder works and these_items will be passed as a text to the dialog!

But this does not work!?:

    on adding folder items to this_folder after receiving these_items
    tell application "Finder"
        set fileName to name of (item 1 of input)
        display dialog fileName
    end tell
end adding folder items to

Strange: I tried with Automator again:

on run {input, parameters}
    tell application "Finder"
        set fileName to name of (item 1 of input)
    end tell
    display dialog fileName
end run

and it WORKS!

What is the difference to the example directly with an AppleScript as above?

Ah, i made a mistake! it should be "these_items" not "input"! Both versions work! Thank you all!

5
  • What is input? If it's an array of alias specifiers you have to ask the Finder or System Events for the name Commented Jan 6, 2023 at 14:53
  • How would i do that? Could you give me a code example! Commented Jan 7, 2023 at 8:13
  • Just wrap the name line in a tell application "Finder" block. Commented Jan 7, 2023 at 9:44
  • See my modification above! It does not work!? No dialog shows up! Commented Jan 7, 2023 at 10:08
  • Sorry, I tried again within Automator and it works here! Thankl you" Commented Jan 7, 2023 at 10:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.