Hope to have settings about Global Inbox

I’m using DT3 to store my files for a long time. But I have a issue now about the Global Inbox import file: I use some tools to transfer the web page into a text bundle format, it will save markdown and photo in one folder. When I use it to save text bundle folder into Global Inbox folder, it will sync into database before it complete the transfer or saving the photos, make it failed. I have to turn off the DT3, complete the transfer then re-open DT3 to import it.

Can we have a options about import time range? for example we can set to 10 mins to detect and import the files from Global Inbox.

In the meantime I will try to change the tools how it save files. Thanks for your help :pray:

This folder is only intended to quickly save documents to DEVONthink but not for slow processes like downloading (probably the case here) or scanning.

1 Like

My custom web clipper works in a similar way. The clipped content is saved to a separate folder before being imported into DT, through a script that is automatically executed. The script also sets custom metadata in DT, using data from the clipped content.

I don’t create a new document directly in DT, because AppleScript frequently messes up with HTML source codes, for reasons I could not determine. Not the same issue as yours. However, the solution could be identical.

1 Like

For AppleScript HTML is just a string, therefore not sure what your script did.

Yikes, that’s exactly why I feel confounded. The HTML source code is generated without issue by Apple Shortcuts. When the source code as text is passed to a Run AppleScript Shortcut action, however, the encoding of the text would sometimes go wrong, and AppleScript would spit out either an error or a document with garbled text.

Apparently there are some quirks when text is passed from Shortcuts to AppleScript. I don’t know what exactly is happening behind the scenes, as debugging is not possible in Shortcuts. Anyway, I did figure out that a temporary file can be used to prevent direct contact between two naughty boys.

(If you wonder why Apple Shortcuts is involved in the first place, it’s because the Get Article using Safari Reader action produces better results than any other web clipper I have tried, including that of DEVONthink.)

Perhaps “Shortcuts” is the issue. That is, imnsho, a piece of broken crap. Not so much because it sometimes fails, but because it fails or breaks unpredictably.

So you pass an HTML document to an AS script? Do do what exactly?

Did I mention that Shortcuts is a piece of crap?

Instead of a Shortcut, I’d use a script (AppleScript or JavaScript, preferabyl the latter :wink: ), which

  • executes Safari’s doJavaScript command
  • the JS code then gets the document source with
    const string = new XMLSerializer().serializeToString(document) (see javascript - How to get the entire document HTML as a string? - Stack Overflow)
  • either return string from the JS code or save it in clipboard in this JS code
  • in your enclosing script, either work directly with the returned string or retrieve it first from the clipboard

Alternatively, using the source property of the relevant Safari tab might give the same result.

That’s just an outline, I didn’t test it. And that will, of course, give you not the same result as passing the document through Safari Reader first. You could try put Safari into reader mode first with a simulated keystroke (I didn’t find another way) and then running the rest of the code. Not nice.

I also found this old post on simulating reader mode. No idea if that works or not

2 Likes

Thanks a lot for the suggestion. I fully agree with you that Shortcuts is full of quirks and thus difficult to work with. That being said, my current workflow is good enough to produce reliable results, so I’m not going to reinvent the wheel unless it fails me :blush:

Maybe just add a tire to the wheel :wink:

1 Like

The Global Inbox in the Finder is just a folder that is watched by DEVONthink, and there is, so to speak, an invisible Smart Rule that has a single purpose: to move every content of that folder into the Global Inbox database as fast as possible.

You can create a folder in the Finder where “some tools” save their content, have DEVONthink index it, and set up a Smart Rule to move in every content to your preferred destination in a DEVONthink database. Just set the trigger not to “every minute” but to some longer interval. In some cases a condition like “date modified is not within the last…” might work too, but probably not so much with bundled files.

3 Likes

thanks, it is the only way to do it. :pray:

we can use this script to finish the file movement

tell application "Finder"
    -- Path to the source folder
    set sourceFolder to POSIX file "/Users/{YOUR_USERNAME}/Documents/Devonthink Import Inbox/" as alias
    
    -- Path to the destination folder
    set destinationFolder to POSIX file "/Users/{YOUR_USERNAME}/Library/Application Support/DEVONthink 3/Inbox" as alias
    
    -- Retrieve all items in the source folder
    set itemsToMove to every item of sourceFolder
    
    -- Loop through each item and move it to the destination folder
    repeat with anItem in itemsToMove
        move anItem to destinationFolder with replacing
    end repeat
end tell
1 Like