Folder actions - on networked folders? AFP? SMB?


Do folder actions work on networked folders?

(I’m trying an smb mounted folder, but the script doesn’t seem to kick in)
Working on synology at the moment, realise this is not OS X filesystem. Can do this on mac in a couple of weeks.

Thank you!

It shouldn’t matter if you’ve mounted the volume as AFP or SMB / CIFS as the action is running on the Mac, not on the server. The folder is just a directory to the OS at this point.

However, Folder Actions can also be notoriously finicky and may not always fire as expected. Does it fail with any attached script?

Here is a simple bit of code that should work as a simple test whether a Folder Action will work with a particular folder…

on adding folder items to thisFolder after receiving theFiles
	display dialog "" & thisFolder & " has received " & (count theFiles) & " files."
end adding folder items to

I mounted my i [/i]PC laptop (appropriately named AbaddonX :mrgreen:) and attached this to a folder on its desktop in the Finder. Then I moved a file into the folder on the PC and…

Screen Shot 2016-03-29 at 2.22.47 PM.png

Hi Jim,

Thx for yor prompt reply! Happy Easter!
New question: I want to copy your example script and use it as a folder action script.
Where do I save the newly created sept?

I tried ~/erwin/Library/Scripts/Applications/Finder but it doesn’t show up?
Or do I need to restart Finder?

Happy Easter to you as well!

~/Library/Application Support/Scripts/Folder Action Scripts (make this folder if you need to)

You can also put them in /Library/Scripts/Folder Action Scripts if you’d like.

They should appear automatically in Folder Actions Setup when you launch it.


Thx for sticking with me - it works now.
Guess I forgot to tick the square “Enable folder actions” - must have overlooked it being obvious when you add a folder action…

Two more issues:
How to go about:

  • adding the item to a specific database “Collection Inbox”?
  • adding also a tag “scanned”?
  • or file them in a Smart Group “from scanner”?

This is the script I’m using:

-- DEVONthink - Import, OCR & Delete.applescript
-- Created by Christian Grunenberg on Fri Jun 18 2010.
-- Copyright (c) 2010-2014. All rights reserved.

on adding folder items to this_folder after receiving added_items
		if (count of added_items) is greater than 0 then
			tell application id "DNtp" to launch
			repeat with theItem in added_items
				set lastFileSize to 0
				set currentFileSize to 1
				repeat while lastFileSize ≠ currentFileSize
					delay 0.5
					set lastFileSize to currentFileSize
					set currentFileSize to size of (info for theItem)
				end repeat
					set thePath to theItem as text
					if thePath does not end with ".download:" then
						tell application id "DNtp"
							set theRecord to ocr file thePath to incoming group
							if exists theRecord then tell application "Finder" to delete theItem
						end tell
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to

're you referring to this…?

This Abaddon

If the database is named “Collection Inbox” and is open, you’d change this line…

 --CHANGE this line >> set theRecord to ocr file thePath to incoming group >> to…
set theRecord to ocr file thePath to incoming group of database “Collection Inbox”
— and add this line
set tags of theRecord to “scanned"

You can’t file things in a Smart Group. Smart Groups don’t contain anything. They merely show files that match given criteria.

PS: I encourage you to dig into this stuff on your own. It can open up many opportunities to customize your setup and create REAL workflows based on your individual needs and working style.
PPS: Some may eschew calling a database by name and referring to it by UUID only. While I agree there are times when this is good, this is still a valid and easy to understand approach for new Scripters.

Yep. :smiley: Evil PCs - LOL. (I am actually comfortable on either platform but prefer Macs by a HUGE ENORMOUS GIGANTIC margin. I have a PC just so I can test our apps in a cross-platform, non-emulated environment. I don’t mess with it much otherwise nowadays unless I’m helping someone I know.)

Thx for your outstanding help!
Message taken: Time permitting, this scripting thing has bitten me a while ago - alas - too little time. But I guess it’s always a median between interest - need & motivation.

We’re at the correct ambient medium temperature now to taste the wine…

I read about being careful with combining with Hazel…
Just acquired this app during the holiday’s - no time to dig into it yet - but will come.
Any specifics to watch out for in this respect?

I will gently remind (and tease) you: A stitch in time, saves nine. :mrgreen:

Nothing specific on Hazel I know of. Believe it or not, as much as I admire Paul Kim’s (Noodlesoft) work on Hazel, I have never used it enough to offer much of a legitimate opinion. (Then again, I have rarely used Automator.) I have always been busy rolling my own solutions. I will say, there are definite ways you must address things in Hazel scripts. You can’t use my little snippet intact with it, for sure.