Need correct Applescript to move a file to specific group

Thank you, @chrillek, for your JavaScripts and explanation. Both you and @rmschne have provided some excellent ideas. I now have to do some research to decide which direction is best for my workflow.

Allow me to chip in, as I also recently left Evernote for DT3.

My workflow included Hazel monitoring an “Inbox” – mine is called “Action” – and applying it’s magic (I have over 200 rules), and then adding the file to Evernote, today DT3.

Below the simple AppleScript. I do not mind it being macOS only, because “once you go Mac, you never go back” ;-). Love my M1 Air btw, it is sssssooooooo snappy! My goodness. Gone are the days of getting my yearly new Air fix!

Anyways.

During my EN2DT3 migration, I wondered to leave Hazel in favour of DT3 Smart Rules combined with the Inbox. I chose to keep Hazel rules because Smart Rules can not be grouped in DT3, so that would become a very long list, as well as due to my familiarity with Hazel, not to forget DT3’s excellent support for AppleScript.

So. Here’s the magic.

--Script start
set DB to "yourDB"

tell application id "DNtp"
	
	--Pulling a Hazel output into strKN – optional of course
	set strKN to item 1 of inputAttributes

	--I'm not using groups as I'm a tag person, therefor need go to the root
	set destinationGroup to get root in database DB

	--theFile is a Hazel variable pointing the file being managed
	set newRecord to (import theFile to destinationGroup)

	--Adding all necessary tags, as well as imported ones
	set tags of newRecord to {"Hazel import", "yourTag", strKN}
	
end tell
--Script end

Enjoy

The M1 MacBook Air’s battery life is insanely good!
And the build quality feels more rigid than previous models. They always felt a bit flimsy to me but this one feels pretty solid.

1 Like

Thank you for the Applescript, @selsrog. I intend to experiment with it when I can devote some time.

I’ve heard nothing but excellent reviews of the new M1 laptops. Mine is a 2018 15" MacBook Pro i9 with 32 GB of RAM. It’s a real screamer, but I still want an M1!!

Oh… one more thing about the M1 MacBook…

My old friend… Yep, it’s back. The startup chime.
:heart: :heart: :heart:

2 Likes

I couldn’t get this to work and get error.

  • Is “yourDB” meant to be the name or ID of the database? I get an error trying both.
  • How do I change root to be Inbox or a specific group within target database? Given that I get error with script as-is, I have bigger issues first.

And which error might that be?

A fairly unhelpful one:

I’m finding more luck hacking this old thread. Given how obvious this operation seems, it is frustrating not to easily find an up-to-date resource explaining, with working example, a basic/generic script to import into a specific db/group.