On modified folder action?

I want to know if there is a way to have a folder action activate when a file is modified, rather than just a file added to a folder. Anyone know?

Applescript User Guide list four actions :
adding folder items to
closing folder window for
moving folder window for opening folder
removing folder items from

You may achieve your goal with an idle handler in a Stay-Open Application.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mercredi 18 janvier 2017 16:53:52

Thanks for the suggestion.

In your idle handler you may use something like :

use AppleScript version "2.4"
use framework "Foundation"
use scripting additions



set currentDate to current application's NSDate's |date|()

set theTarget to ((path to desktop as text) & "sourceFolder:") as alias

-- make URL
set targetURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of theTarget)
set modKey to current application's NSURLContentModificationDateKey
set theFileManager to current application's NSFileManager's defaultManager()
set theEnumerator to theFileManager's enumeratorAtURL:targetURL includingPropertiesForKeys:{modKey} options:((current application's NSDirectoryEnumerationSkipsHiddenFiles) + (current application's NSDirectoryEnumerationSkipsPackageDescendants as integer)) errorHandler:(missing value)
set anArray to current application's NSMutableArray's array()
repeat with anItem in theEnumerator's allObjects()
	set {theResult, theValue, theError} to (anItem's getResourceValue:(reference) forKey:modKey |error|:(reference))
	if (currentDate's timeIntervalSinceDate:theValue) < 60 then
		(anArray's addObject:anItem)
	end if
end repeat

# List of files modified since less than 60 seconds
anArray as list

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mercredi 18 janvier 2017 18:34:51

Hey T_Rex,

There’s nothing very turn-key that’s stock-macOS to do this job (that I know of),

You can play games with the command-line tool fs_usage, but I think that will get overly intense usage.

LaunchD might work, and that’s stock (although you might want a utility to help write the plist).

There are some other options as well “ take a look at this discussion on StackOverflow:

http://stackoverflow.com/questions/1515730/is-there-a-command-like-watch-or-inotifywait-on-the-mac


Chris
··················································································
{ MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.12.2 }