Folder Action to launch an app's "on open" handler

Hi

I am trying to work out to write a folder action script that launches a separate AppleScript application that will process the files/folders dropped in the hot folder as if the item was dragged and dropped on the application icon itself.

In other words I’m trying to write a folder action that runs the app’s “on open” handler and then processes the dropped files one by one.

P.S. I also have an “on run” handler in the app which runs when the application when clicked on by the user (this handler is used to change setting etc).

I have the application done and it works fine when items are dropped on it. What I can’t work out is how to write the folder action script so that I can have a hot folder that does the same.

Hope this is clear.

Any help would be appreciated.

Thanks

Tim

You may try something like :

on adding folder items to this_folder after receiving these_items
	set targetApp to ((path to desktop as text) & "droplet.app:") as «class furl»
	tell application "Finder"
		open these_items using targetApp
	end tell
end adding folder items to

I tested it with the droplet “droplet.app” whose code is :

#=====

on open sel # sel contient une liste d'alias des éléments 
	# qu'on a déposés sur l'icône du script (la sélection)
	
	repeat with aFile in sel
		set itsName to name of (get info for aFile)
		display notification itsName sound name "Ping"
		delay 2
	end repeat
end open # 

#=====

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 16 janvier 2020 15:45:25

Thanks Yvan

That should do the trick! :slight_smile:

Hi timbaldwin

I think it’s a bit unfair to “request” something final in a forum unless you put a bit of effort yourself and share your wisdom with the community

The reason is simple, we gather here to learn and help each other, happy to be part of the whole.

You’re welcome to contribute with your own ideas to share an unique experience with us all, so everybody can enjoy to be online here.

Hi Joy

I am not sure what you mean… My request was not for anything final. Please read the post and you will see that I had a problem with one aspect of a calling a script application that I had already written.

If you are unable to help please feel free not to help.

I am not sure discouraging people from seeking help is very productive in this type of forum.

Tim