Simple Automator Folder Action Not Working

I have setup two folder actions, the first moves files from downloads to a holding folder and another to deleted specified files from another folder.


The first one is working great after following a few troubleshooting steps I found, the second works in Automator, using the "Get Specified Finder Items" action, as well as once I remove this step and use the "Show this action when the workflow runs" on my "Filter Finder Items" action. This brings up a popup confirming the action, which I leave at the default and click ok. Leaving this option in place defeats the purpose of the workflow since it requires manual intervention.


Second Workflow:

1)Filter Finder Items

2)Move Finder Items to Trash

MacBook Pro, iOS 10, 10.11.6

Posted on Aug 1, 2018 5:31 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 5, 2018 1:43 PM

This is what I changed it to, its working perfectly. It was constantly prompting me, and that was the only place there was a prompt for files.

# application double-clicked or run from the Script Editor

on run {input, parameters}


doStuffforinput

end run

# process a list of file items

to doStuffforsomeFiles

repeat with anItem in someFiles

set anItem to anItem as text

tell application "System Events" to set {theClass, theName} to {class, name} of disk itemanItem

if (theClass as text) is not in {"folder", "«class cfol»"} then -- a file or bundle

tell application "System Events"

set extension to name extension of disk itemanItem

if extension contains "added" then deletedisk itemanItem

end tell

end if

end repeat

end doStuff

Similar questions

15 replies
Question marked as Top-ranking reply

Aug 5, 2018 1:43 PM in response to red_menace

This is what I changed it to, its working perfectly. It was constantly prompting me, and that was the only place there was a prompt for files.

# application double-clicked or run from the Script Editor

on run {input, parameters}


doStuffforinput

end run

# process a list of file items

to doStuffforsomeFiles

repeat with anItem in someFiles

set anItem to anItem as text

tell application "System Events" to set {theClass, theName} to {class, name} of disk itemanItem

if (theClass as text) is not in {"folder", "«class cfol»"} then -- a file or bundle

tell application "System Events"

set extension to name extension of disk itemanItem

if extension contains "added" then deletedisk itemanItem

end tell

end if

end repeat

end doStuff

Aug 1, 2018 10:11 PM in response to Ryan-423

If those are the only two actions in the workflow, my guess would be that the filter action is not finding anything - note that it uses Spotlight, so if the items are not indexed (yet) there may not be any results. Another way to troubleshoot would be to add something like a Copy to Clipboard action after the filter action to see what its results are.

Aug 5, 2018 1:56 PM in response to Ryan-423

Ah - you placed the script into a Run AppleScript Automator action. The script as originally posted was stand-alone did not need Automator at all. Placing it into the ~/Library/Scripts/Folder Action Scripts folder was all that was necessary to have it show up in the Folder Action Setup service, with the extra benefit of it being able to be run in the Script Editor for testing.

Aug 3, 2018 5:32 PM in response to Ryan-423

The only thing I can think of is that the file gets indexed when showing the dialog; Automator is just goofy that way. You can use the following script instead - it doesn't use Spotlight and can be run as an application, from the Script Editor, or as a folder action (for the latter, place the script in your user's ~/Library/Scripts/Folder Action Scripts folder):


# application double-clicked or run from the Script Editor
on run
  doStuff for (choose file with multiple selections allowed)
end run

# file items dropped onto the application
on open theFiles
  doStuff for theFiles
end open

# process a list of file items
to doStuff for someFiles
  repeat with anItem in someFiles
    set anItem to anItem as text
    tell application "System Events" to set {theClass, theName} to {class, name} of disk item anItem
    if (theClass as text) is not in {"folder", "«class cfol»"} then -- a file or bundle
      tell application "System Events"
        set extension to name extension of disk item anItem
        if extension contains "added" then move disk item anItem to (path to desktop)
      end tell
    end if
  end repeat
end doStuff

# handle file items added to a folder
on adding folder items to this_folder after receiving these_items
  doStuff for these_items
end adding folder items to

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Simple Automator Folder Action Not Working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.