Debugging folder actions

I’ve set up Folder actions and connected them to an AppleScript I created. I added a dialog at the beginning of the script to confirm the script is really running. But, the workflow doesn’t seem to do anything.

I’m not entirely sure my workflow is set up right. I put an empty “Read Individual Files” at the beginning. Is that correct, or should I be using something else to get the input from AppleScript?

Note that if I add an image to the blank Read Individual Files and run the workflow, it does what I expect.

Is there a way to confirm my workflow is actually being run? My workflow includes a JavaScript node and I don’t see any logging from it in the Retrobatch console…

This is my AppleScript:

use AppleScript version "2.4"
use scripting additions

on adding folder items to theAttachedFolder after receiving theNewItems
	
	display dialog "Running forum action!"
	
	tell application "Retrobatch"
		set d to open "/Users/jacquesf/Documents/Forum Photos.retrobatch"
		tell d
			execute input items theNewItems
		end tell
	end tell
	
	tell application "Finder"
		-- Uncomment the following line to move the items to the trash.
		-- move theNewItems to the trash
	end tell
	
end adding folder items to

I’ve confirmed the path to the workflow is correct:

$ ls "/Users/jacquesf/Documents/Forum Photos.retrobatch"
/Users/jacquesf/Documents/Forum Photos.retrobatch

Here’s my workflow…

You shouldn’t need the Read files node in front, RB will synthesize on for you.

I’m not sure why it’s not running, it should!

The first time the script is run, you’ll get a warning like ““FolderActionsDispatcher.app” wants access to control “Retrobatch.app”. Allowing control will provide access to documents and data in “Retrobatch.app”, and to perform actions within that app.”

Did you allow that to happen?

And secondly, are you using the App Store version of Retrobatch or the version off the website?

-gus

I’m using the website version of Retrobatch.

I don’t recall getting that prompt.

When I navigate to System Settings > Privacy and Security > Automation, FolderActionsDispatcher does not show up. It does show up under Files and Folders, however (and both Documents Folder and iCloud Drive are checked).

I did notice that every time I add a file to the folder, Retrobatch comes to the front. It still doesn’t seem to do anything, though. I commented out all of the tell application "Retchbatch" block in my applescript and then Retrobatch stopped coming to the front when I add files to the folder.

So, Retrobatch appears be getting invoked, just not running my workflow in any meaningful way.

I tried doing tccutil reset AppleEvents and that didn’t change the behavior. Retrobatch comes to the front when I add a file to the folder, but nothing else happens and I don’t get a TCC prompt.

Can you grab the latest build of Retrobatch from the following URL and replace it with the one you’re using? https://flyingmeat.com/download/latest/#retrobatch

I’ve changed a few things having to do with reading the files from AppleScript, and I’m hoping it’ll help.

Also, if nothing good comes of it, can you bring up the console and then run your AppleScript? You can open it via the Window ▸ Console menu item.

-gus

Version 2.1b1 (1473) doesn’t seem to behave any differently.

I opened the Retrobatch console window before triggering the folder action (via moving a file into the watched folder) and nothing showed up in the console. If I run the Retrobatch workflow manually, I see this in the console:

Switching to JavaScript runtime <FJSRuntime: 0x10d7bf1d0>.
2024-03-11 03:23:03 +0000 Starting process
2024-03-11 03:23:03 +0000 Finished process - 0.04 seconds, 0 pixels processed

Maybe this is getting somewhere? I tried creating a standalone script to narrow things down a bit from folder actions. I’m not very good at applescript, but hopefully this is simple enough:

use AppleScript version "2.4"
use scripting additions

set theNewItems to {"/Users/jacquesf/Documents/Photography/Process/Forum/Forum 2024-03-08 Golden Gate Park 0004.jpg"}

tell application "Retrobatch"
	set d to open "/Users/jfortier/Documents/ForumPhotos.retrobatch"
	tell d
		execute input items theNewItems
	end tell
end tell

When I ran this, Retrobatch came to the front and then a couple seconds later I got a Script Error dialog with this error message:

missing value doesn’t understand the “execute” message.

The files I reference in the script all seem to exist:

$ ls "/Users/jacquesf/Documents/Photography/Process/Forum/Forum 2024-03-08 Golden Gate Park 0004.jpg"
/Users/jacquesf/Documents/Photography/Process/Forum/Forum 2024-03-08 Golden Gate Park 0004.jpg
$ ls "/Users/jfortier/Documents/ForumPhotos.retrobatch"
ls: /Users/jfortier/Documents/ForumPhotos.retrobatch: No such file or directory

:man_facepalming::man_facepalming::man_facepalming::man_facepalming::man_facepalming::man_facepalming:

When I was debugging earlier, I noticed that I had the wrong path to my workflow, fixed it, and then somehow fat-fingered my script back to having the wrong path again. I’m glad I thought to re-check while sending this latest update.

Sorry for all the noise. I’m wondering if there’s a way Retrobatch can help with a useful error message in this case. (I’m guessing not, but you never know…)

Hooked it all up to my forum action, got the TCC prompt, the workflow ran, all good.

1 Like

Well, AppleScript gave the error message, which I think is the right spot, since it couldn’t convert the missing path into a document. You can turn on additional logging with the following defaults command:

defaults write com.flyingmeat.Retrobatch showDebugLog 1

But I’m not sure it would have helped in this case.

I’m glad it all got sorted out! I think another solution would have been to give RB full disk access. I had it turned on for myself and everything ran as expected, but when I turned it off the Folder Action failed (and that’s what the new build fixed).

-gus