Global Inbox workflow

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...

The tweaks on this script get more complex. I don’t quite comprehend the request, but you want the script to do what it does and do something different at the same time? So, setting aside (1) which doens’t work with (2), let’s think about (2). Normally, “Reveal” means “I found something in Search and I want to navigate to the place where it is – so I’ll use command-R to get there”. What you see when you “get there” depends on the View (Icons, List, Columns, Split, Three Panes, Tags). I don’t think what you want is “Reveal”. (Of course, GUI scripting could be used here, telling System Events to keypress command-r, and so forth.)

If you don’t want the document to appear in its own window, then use a tab, instead of the open window command:


set theTab to open tab for record theRecord in think window 1

If theRecord is already visible in think window 1 then you won’t be shown a new tab, you’ll just be shown the document. But, again, the result depends on the View. Experiment and adjust the script as necessary.

Thanks very much for your help with this. I created a fresh script, and included your suggested change. Here is the full script with that revision:

-- 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
								set theTab to open tab for record theRecord in think window 1
								
							end tell
						end if
						
					end try
				end repeat
			end tell
		end if
	end try
end adding folder items to

I understand what you mean about the complexity of the change – and I appreciate that.

I’ll try to better explain my thought process behind my request. First, the main part of the script works perfectly as far as placing files into the exact DTP group. It’s great. But: (1) Users have rightly pointed out that trigger scripts aren’t 100% reliable (in this case, with saving files in DTP), and (2) after saving files in DTP, one has to often close the original document in the app from which it was originally created (e.g., Word, TextEdit, etc.) – unless they were created within DTP, of course – and then re-open the saved file from within DTP to resume working on them.

The new revisions to script as far as opening it in a new window is great (I certainly appreciate it) but for my purposes it would be better to reveal file in its DTP group after it has been saved because (a) It would verify that the script successful placed the file in the DTP group, (b) it wouldn’t have to process the file by opening it in a DTP window (as is the case with Word files, for example, which can be a bit lumbering) - and isn’t always necessary if I don’t need to work on that file further, and © just revealing the file in its DTP group would make it easy to select and open it in DTP or an external app, if I need to work it further. (BTW, I thought such a reveal function might work best in List view, since it doesn’t need to process a preview of the file.)

I hope I’ve done a better job of explaining this. I’m certainly open to another, suggested process. And I’d certainly appreciate any suggestion adjustments to the script you might recommend. Thank you again for your help.

I have another idea that might work… Instead of trying to use “reveal” (at least in the context that I’ve described) is there a way to change the script so that after users deposit files into their group (i.e., through the "Groups & Tags panel) the opens the “Newly Saved” or “Today” smart folders (in List view)? That would essentially accomplish the same thing, and it might be easier to do.

Thanks for considering this.

You could always try writing it that way yourself – a good learning experience :confused:

I’m certainly happy to try, though I don’t know a thing about writing code – for AppleScript or otherwise. I’m a total novice. Still, I’m happy to give it a shot. Any suggestions for figuring out how best to get info about how to accomplish this? Or is there a relatively simple line you’d suggest that would accomplish opening the “Newly Saved” or “Today” smart folders in a List window? (Not sure which folder would be the best.) I suspect I would only need to change the same line of code:


set openMe to open window for record theRecord

Correct?

Thanks.

Smart groups are not scriptable. They are dynamic, saved searches.

Ok. So it’s not possible after all. Pity.

Thanks.

For what it’s worth, I have a smart group for “recently added” and when looking at files there I use the “Move” script which has a keyboard shortcut to move the files quickly and easily to the appropriate databases and/or groups. For me, this is a quick and easy process.

Thanks so much for this! When you’re referring to the “Move” script is that the same as the “Move to…” script? i.e., the script from this post: [url]improving Move To] Thank you for your helpful suggestion - very much appreciate it.

i’ve recently been using this script to deposit files from word and other app’s int dtp’s databases & groups. i’m also considering the “move” script cited in this forum, but the advantage to this script compared to the “move” script seems that one can just use the folder action script to from an outside app (like word) to deposit files directly into the desired databases & groups, correct? whereas one has to do this process both from w/in and outside app and dtp w/ the move script.

is this an accurate assessment?

also, two questions about using this script:

(1) is there a way to check the contents of the folder (for the folder action script) against what has been deposited into dtp? I ask because, as one member here noted, sometimes the script fails to fully execute - and in some cases, i’ve continued to use the original file after i’ve deposited in to dtp using this script - which has meant that i wasn’t saving my file to dtp, but the file in the folder the folder action script.

(2) i was struck by one question raised on this forum: “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?” i’m curious if there’s a good answer here (e.g., using hazel or some similar app) - that is, after ensuring that step 1 (outlined above) has been fulfilled.

thanks.

Just wondering if there was any additional ideas / suggestions about this…

Thanks!

I know it’s been along time, but I’m just wondering if there’s been any update to this folder script.

Thanks!

Instead of folder actions it’s now usually recommended to use smart rules & indexing.