Global Inbox workflow

Thank you!
H

Thank you very much Korm!

It was not deleting the file for me so I added the missing part.

-- DEVONthink - Import & Delete.applescript
-- Created by Christian Grunenberg on Fri Mar 26 2010.
-- Copyright (c) 2010-2012. All rights reserved.

on adding folder items to this_folder after receiving added_items
	try
		if (count of added_items) is greater than 0 then
			tell application id "com.devon-technologies.thinkpro2" to launch
			tell application id "com.devon-technologies.thinkpro2"
				set theGroup to display group selector "Select the destination group"
				repeat with theItem in added_items
					try
						set thePath to theItem as text
						if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
							tell application id "com.devon-technologies.thinkpro2"
								set theRecord to import thePath to theGroup
								
								if exists theRecord then tell application "Finder" to delete theItem
							end tell
						end if
						
					end try
				end repeat
			end tell
		end if
	end try
end adding folder items to

I’m just getting started with applescript and this was a great lesson.

Thanks again!

Sincerely,

Just updated my DTP setup a bit, and included the features in this post. @korm created a brilliant little script, and @devananda was a welcome update since it ensures that the folder is properly deleting files.

I sure hope DTP includes something like this for future additions! In my view, it’s much needed…

By the way, is anyone still using “Default Folder X” when saving files to DTP (or similar apps)? If so, why? Namely, how does it help your process?

Thanks!

I’ve used Default Folder X since it first came out, and every three months I think “why am I using this” – then I turn it off and a few months later I turn it back on because, well, I own it so maybe it will be useful. It is rarely useful. Someday I’ll just uninstall it.

Hmmm… Not exactly a ringing endorsement! Well, if you made the case for using it in some meaningful way I might consider it… Anyway, thank you for your response. Appreciate it.

I find Default Folder X very useful for saving to the OS filesystem through its Favourites icon - it is much faster to work through a hierarchy of sub-folders that way than using Finder Favourites. It’s also convenient for adding Spotlight Comments and I occasionally save in a different format using its options. Perhaps not a compelling case for buying it, but as Korm says, once you have it …

Ok, great. Thanks. Could one use Default Folder X for going through DTP’s hierarchy of sub-folders (or groups and subgroups)?

Thanks!

No, unfortunately, only Inbox is accessible through Default Folder X. My workflow for saving a file to DTP’s hierarchy (for example a file currently being viewed in Preview) is to drag the mini icon on the title bar (of Preview in this example) onto the DTP icon in the dock. This opens up the hierarchy, which you have to click through to get to the one you want. An alternative, if you have DTP’s Groups & Tags window open, is to drag the mini icon onto that - this reveals sub-folders as you mouse over parent folders with the dragged icon, so can be quicker.

DFX Favorites can be useful in Save As dialogs when you have indexed those Favorite destination folders into DEVONthink.

There seems to be a bit of overlap here between this thread on this post, and this one: [url]Any new, improved Phone Note scripts or templates?] But it seems that the original query is contained to this post, so to that end…

I’ve been using the script that was created by @korm and then revised by @devananda (the main change being that it automatically deleted files from the folder). It’s a brilliant script, and I really wish DTP would appropriate these functions in future editions. Anyway, I’ve not been making additional changes to the way in which I tag-and-replicate files that I store in DTP – and therein specific groups/subgroups (per @korm’s advice). I confess I haven’t fully implemented this yet, since this it’s a very new process and modality for me! Anyway, it seems like a way to more easily, and quickly, store and replicate files.

So…even though this might be a bridge too far (and if it is, please say so), I’m wondering if there’s a way to add another feature to the folder script: namely, one that would allow users to also add tags to files that are being saved/stored in DTP (in the way that DPT’s browser clippings functions). In that way, it seems that the folder function will allow users to kill two birds w/ one stone, right?

I have not expectations about this – just tossing this idea out there… Really look forward to hearing your thoughts about this… Thanks!

For my use, I have written a folder action script that does this bit of prompting for tags (I don’t post scripts here anymore so won’t be adding this to the reply).

In practice, I found it an annoying add-on for two or three reasons. I frequently put more than one item into a folder and a “tag me” dialog opening for each one is too much of an interruption. Also, OS X does not always process folder actions rapidly and when a dialog is involved in the action OS X frequently gets “confused” and forgets to pop open the dialog. Finally, this bit of adding tags is better handled by DFX – or, better yet, natively in Yosemite’s Save As dialog at the time the file is saved in the folder-action folder than after the file is saved.

Gotcha. So…if I understand this correctly, DFX cannot be used to save files in DTP’s hierarchy of sub-folders (or groups and subgroups), but can be used to apply tags to files (as one is saving them to DTP) – and those DFX-applied tags are transferrable to DTP. Is that correct…?

If so, why then is it preferable to use Yosemite’s Save As dialog to apply tags rather than DFX (given some of the shortcuts you mentioned for DFX)? Thanks…again!

The former is free. The latter isn’t.

I’ve been implementing many of the suggestions outlined in this thread, and it has been very helpful. So, thank you all for your input. In so doing, I just remembered the one part of this process that tripped me w/ the trigger script. Again, it’s a wonderful script, esp. the latest iteration. But I forgot that one cannot save to a file that has been created outside of DTP, and then stored in DTP’s groups through this method – that is, until one closes the file, nagivates to its newly-stored location in DTP, and then opens it from there (in the case of a Word file, one typically opens such a file externally – at least in my case).

Is there an recommended alternative to this? Or a fix to this problem? Or even a script that can provide a solution?

Many thanks…

The script above is not a “trigger script” - it is a folder action script. There’s a difference. Doesn’t matter what it is, but there’s a difference.

Let’s say you create a Word file and save it to a filesystem folder that has the folder action script attached. (Using Word just as an example – the following applies to anything created outside of DEVONthink.) The folder action activates, asks you where to stuff the file in DEVONthink, and then does so. But, you want to continue editing that file. It’s no longer where Word thinks it is.[^1}

Don’t be looking for a new script to address this[^2] – there are much simpler approaches.

  1. If you are editing a pre-existing Word document that someone gave you or that simple was stored in the file system. First, move the file into DEVONthink – before you start your editing session – and then use Open With in DEVONthink to start your editing session.
  2. If #1 is too much work, then save your work in progress to an indexed folder and later on move the document into DEVONthink – or don’t, and just leave it indexed.
  3. If you are creating a new document from scratch, first navigate to the group in your database where you want to keep the file, and create a new (blank) Word document from Data > New from Template > Office. Or wherever it is among the document templates that you store you Word template – if you don’t have a template for each file type that you commonly use, then you should create them. Then, as above, use use Open With in DEVONthink to start your editing session. This is the process I use 99% of the time when I need a new file of almost any sort – I create a new file with a template then open the new file in the external app and proceed.

[size=85][^1] There are a few Mac apps that have sufficient situational awareness to know when a file that is open in the app has moved somewhere else in the filesystem. Unfortunately this is the exception, not the rule, and one cannot rely on developers to do things this way.[/size]

[size=85][^2]Here’s the thing – a script that tells an app “that file you’re editing? it’s moved. here’s the new address” will not be possible because most applications will ignore the message – and for reliability and the sake of your data, you don’t want an app to be receiving external commands like this.[/size]

Thank you very much for this…I apprecaite it. Yeah, I figured it was a bit of a reach to put something like that together, but it doesn’t hurt to ask. It definitely requires a different work approach; in a way, I have to think in reverse – opening a file from within DTP to create a file in Word (or perhaps in Ulysses, if I can get a better sense of how it best serves my interests). Plus, I don’t necessarily have DTP open all the time. I hadn’t thought of the Index option you mentioned in #2. (I don’t use Index often, just for media files, so I’d have to think through how best to set something like that up.)

Let me ask you this… Is there some kind of shortcut for option #3? – Anything that could just expidiate the process? I sometimes launch various kind of templates / folders w/ Quicksilver. Any chance there’s a way to create something like that w/ a DTP template? Maybe it’s even possible to open such a template through that (or other) means w/o opening DTP…?

Thank you again for your generous help.

I use this wonderful script routinely, and really thank @korm for conceiving it and for[b] @devananda [/b’s] update to ensure that the folder deletes files after the action. I don’t know how to build scripts, but I’m wondering… Is it possible to perhaps tweak it by creating a checkbox for the “choose destination” panel that, when check, could automatically reveal the file in DTP after it has been saved? If so…that would really make this script even more amazing! For me, it would just hasten my workflow, and make things go much more smoothly.

I know such an idea / request would require work, so I thank you for considering it (if it’s even possible)!

Thank you!

If you were following along in the forum:

In the script above, change


set theRecord to import thePath to theGroup
-- if exists theRecord then tell application "Finder" to delete theItem

to this


set theRecord to import thePath to theGroup
-- if exists theRecord then tell application "Finder" to delete theItem
set openMe to open window for record theRecord

I see I never responded to this, I see. Personally, I don’t want DEVONthink deleting things for me. Folder actions are not 100% reliable in OS X – they can fail. I intentionally did not include the code to have Finder delete documents. For me, it is not an improvement or something missing. It’s no thing to go clean up that folder when I’m sure the action succeeeded. So, that’s why in the code above I commented out the suggested addition. Add it back, for those who want. :neutral_face:

So glad you mentioned that, @korm, because I frankly thought that the folder action script would be fairly automatic. But if it’s not 100% reliable, then yes, I agree that I should use the script w/o the auto-delete function. Maybe I’ll implement your script (the one that opens or reveals the saved item), and then set up Hazel in such a way that it will automatically trash older files from the folder. Think that would work best?

Just so I’m clear on which code to copy and apply, because there’s a bit of back and forth on the forums… You are saying I should first copy the very first script you created in the “Opening added item with Folder Action” forum, and then make the code replacements above, correct?

And does the script open the newly saved file or just reveal it? Thanks so much!

I’ve compiled, saved, and attached the following folder action script: [url]Put up Example page]

When I applied, this script launch DTP’s “Show Groups & Tags,” and enables me to save files in my particular DTP group of choice. I was instructed to make changes to this script, found in this post [url]Put up Example page] to prevent the folder action from deleting files – just in case they weren’t securing placed into my groups / folders.

I am wondering:

(1) How can I maintain this script’s features, and also

(2) …include a feature in the script that would enable me to could automatically reveal the file in DTP – not open it – after it has been saved?

I hardly know anything about code, but I suspect there’s a way to tinker with the following: ```

set openMe to open window for record theRecord


Finally, in lieu of using a folder action script to automatically delete files, what do people suggest one does to regularly cleanse the folder (the on with the attached folder action script) to prevent it from clogging up and creating extraneous duplicate files?  

Thanks very much...