You’re not adding a new script. You’d select it in the Folder Actions Setup window and press the Edit Script button.
An edit would look something like this…
tell application id "DNtp"
set theRecord to import path thePath to incoming group
perform smart rule name "Beep" record theRecord
if exists theRecord then tell application "Finder" to delete theItem
end tell
Running a smart rule every minute should only be used in very specific circumstances, not for general use. Imagine you are waiting for a parcel in the mail. Would you run and throw open the front door every minute, just in case it was delivered in the 30 seconds since you walked away? While you could, I think you’d agree it’s inefficient and wasting energy.
@BLUEFROG awesome this would be super useful for many things!
Last question, this works well (just tested) for my video files, yet since i ditched hazel and use DEVONthink for all my capture and automations, i put many other file types (pdf, images, md etc) in my capture folder (DTimp).
Should i have a separate folder action/script for each filetype i want to import and run a smart rule, or should that all be in the same script and launch a smart rule based on the file type (ie have the applescript identify the filetype and run the smart rule)?
I can’t answer this specifically for you but either option is potentially viable. Personally, I would set things up separately so I could debug and polish the process for a few file types. Then I’d live with it for a bit and see how it feels. I would then assess the setup later and decide if combining them is worth it.
im circling back to this as i have allocated some time today to try and advance with this
based on the previous posts i can start creating separate folder action scripts per each import i do (bills, insurance, work, life, fuel etc) so that each import immediately launches a smart rule in real time but i want to confirm first:
@BLUEFROG reading your post again here Smart rule on importing - #4 by BLUEFROG
you seem to suggest its better not use the folder action method but just index my import finder folder into my database?
is that still the way you recommend fin DEVONthink 4?
if thats the case, how do i account for the indexing of external folders? do i need to have a script that reindexes often?
yet when it executres as opposed to the finder folder action import&delete the move methond in my smart rule seems to leave a copy in the finder folder:
i still cant get it to work, i setup everything correctly it think but DEVONthink does not seem to respond to new files in the action folder.
im created a short video to better show the entire process:
as always really appreciate the help, would love to get this up and running finally!
Have you chosen a cloud-synced folder? DefaultFolderX makes things look odd. It is well-known and documented such folders don’t always reliably provide notifications about filesystem changes and often require using File > Update Indexed Items when the indexed group is selected.
Also, your video shows you adding a new folder as an indexed group but there’s nothing showing you’ve adjusted the smart rule to target that group?
You might run into trouble if your cloud service does weird things with this folder (like “optimizing” space, which iCloud pretends to do).
And the issue here is not so much that it’s a symlink, but that your cloud service probably does not send the same file system events macOS does.
The alternative to pushing things from here to there passing through a third location might be to update your indexed folder regularly. This could perhaps be achieved by a smart rule running every hour or so and executing a synchronize command for the folder.