You don’t replace ‘this_folder’
‘this_folder’ is a variable that is set by folder actions to identify the import folder
‘added items’ is another variable identifying the actual items
You might want to look at the sample DT folder action scripts in ~/Library/Scripts/Folder Action Scripts
so it adds items to …
The scripts will have code such as tellapplicationid “DNtp” … set theRecord toimport thePath to incoming group
You can replace “incoming group” with your specific group
Welcome In future, please could you post the script which you are referring to - I can’t find a script of the description you described on my Mac, so I can’t really point you to specifics. Also: if you paste script enclosed in ``` (backticks) then it will be rendered as script by the forum software. Single lines are posted as ```a line``` and code blocks as
```
a block of code
```
Back to the topic at hand: somewhere in the script you reference there will be a line something like set this_folder to get record at "/group/subgroup" in database "a_database"; if you change that line to point to the group and database you want, it will probably work (I say probably, because I don’t know what the script is doing, and can’t guess from the single line you have posted).
Thanks all, for the great and helpful replies! feel very welcome as a new community member. I just purchased Devonthink a few days ago.
I tried it at the bottom of this post to paste the script with the suggestion by Blanc (thanks!)
Btw, the script shows up then I create a folder action. There are a number of Devonthink scripts that I can select at this point.
What do you think would word to have this script auto-import in this specific database group?
Database mydatabase
Group mdbgroup
Thanks so much!
-- DEVONthink - Import, OCR & Delete.applescript
-- Created by Christian Grunenberg on Fri Jun 18 2010.
-- Copyright (c) 2010-2017. 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 "DNtp" to launch
repeat with theItem in added_items
set thePath to theItem as text
if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
set lastFileSize to 0
set currentFileSize to 1
repeat while lastFileSize ≠ currentFileSize
delay 0.5
set lastFileSize to currentFileSize
set currentFileSize to size of (info for theItem)
end repeat
try
tell application id "DNtp"
set theRecord to ocr file thePath to incoming group
if exists theRecord then tell application "Finder" to delete theItem
end tell
end try
end if
end repeat
end if
end try
end adding folder items to
The script is sending the files to the incoming group ( set theRecord toocr file thePath to incoming group)
Change this to set theRecord toocr file thePath to specificGroup
You need to define specificGroup @Blanc’s example above is set specificGroup to get record at “/group/subgroup” in database “…”`
I use get record with uuid “…” in database “…”
The uuid is extracted from the item link of the group record, for example 9503FF96-95A8-439A-AF2D-FF2F1094EC91
The jpgs go into Users > maik > local > source
Files are added automatically in the folder by a training software that exports screenshots every few seconds. We use the final OCR pdfs to improve learning sessions and quickly zoom into specific past user scenarios and actions.
Thanks so much. Trying my best here with limited scripting knowledge.
Something very obvious is still wrong though. Hope I am moving in the right direction.
-- DEVONthink - Import, OCR & Delete.applescript
-- Created by Christian Grunenberg on Fri Jun 18 2010.
-- Copyright (c) 2010-2017. 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 "DNtp" to launch
repeat with theItem in added_items
set thePath to theItem as text
if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
set lastFileSize to 0
set currentFileSize to 1
repeat while lastFileSize ≠ currentFileSize
delay 0.5
set lastFileSize to currentFileSize
set currentFileSize to size of (info for theItem)
end repeat
try
tell application id "DNtp"
---my changes start here
set specificGroup to get record at “52A1A40A-BF7E-4227-96EC-421D172ADF87” in database “screenlog”
set theRecord to ocr file thePath to specificGroup
---my changes end here
if exists theRecord then tell application "Finder" to delete theItem
end tell
end try
end if
end repeat
end if
end try
end adding folder items to
If something is “obviously wrong”: Do you get an error message? Which one? If not, what is wrong?
Apart from that: Can anyone explain to an AppleScript agnostic what this repeat while lastFileSize... loop is trying to achieve? If anything - neither lastFileSize nor currentFileSize seem to be used outside of that loop.
You might want to look really (really!) close at the quotation marks you use in that line – this is a programming language, so no curly quotes for strings
Oh, and please always post error messages right away if you get them: “it does not work” is not helpful for anyone. Neither is “obviously wrong”: if it where obvious, there’d be no need to hunt for a bug…
if you are using the UUID, you need to use set specificGroup to get record with uuid "52A... (and as @chrillek pointed out, your quotation marks are curly…)
I would guess this pauses the script until the file has stopped changing its size, i.e. been fully downloaded. Presumably the if condition the loop is encapsulated in will catch files being downloaded by some browsers (as they add e.g. .download to the file name until it has finished downloading), but not all - so that the loop catches the rest. I’m not sure about that though, because the delay is quite short and a slow download could easily not change its size for 0.5 s. So possibly there is some other mechanism involved (the browser compiling the finished/downloaded file?) which is not instantaneous and would be caught be the loop.
OMG. Wait states instead of callbacks or promises… Not that I’m a big fan of the latter ones, but this?
Wouldn’t it be possible to use a folder action thus avoiding this clumpsy CPU hogger?
I guess not (because I guess Criss would otherwise have done so); having a quick look, it’s not apparent that the folder actions could be set to avoid triggering on a new, but not yet complete file. But I’m really only guessing here.
I would forgo the folder action and scripting and index the folder into DEVONthink. You could then employ a fairly simple smart rule to move the file into the database, do OCR, then move the item to a desired location in a database.
As others pointed out - check your use of the quotes character
I hope you’re not discouraged with scripting by this
It’s a minor error, with the exact line highlighted
All, thank you for the great advice. the corrections above, the script does not return any more syntax error. Will test over the next few days how it works! Appreciate everyone’s patience with me Scripting noob.