how do i navigate records in a window

As some you have already helped me with pieces of this, you know what some of my issues are, but this is a more broad question so I am posting as a new thread:

Assuming I have a selected window, is there a way to step through records in that window? Can I do it sequentially? (as in, next record in window 1) Can I do it by numerical reference (record 2 of window 1) Or is there another way to do it?

The way I have handled this before is to use a selection and loop through the selection. But my current need is different for the first file than it is for the rest of the files. So I would like to use the first file (a sheet) to define an array, then use the elements of that array to assign values to fields in the remaining files. So the values in a sheet build an array such as this:

theCustodianArray {Custodian Bill Jones, Custodian Jim Jones, Custodian Carl Jones}
then those custodians are all assigned as tags to the pdfs below the sheet in the folder, files (or records?) 2, 3, & 4 in the current window.

does that make sense?

thanks in advance.
chris

If I understand what @gelbin wrote in the OP, you want to control the interface with a script. The script would inspect the contents of a “sheet” (really, just a .csv document), and based on those contents it would assign tags to certain other documents in that folder (i.e., group in DEVONspeak). This is a rather complicated script.

Isn’t it faster just to tag the documents? There are scripts in the library or support assistant to help automate tagging.

the csv file will have thousands of entries. the idea is that i am translating metadata fields from another database source into dtpro. you guys have helped me to the point where I have read the column values into an array of the metadata, now I want to go down the files/records in the folder one by one and assign those to fields for each pdf, in this case, assign them as tags. does that make any sense?

alternatively, if i could, mid-script, stop and ask for a new selection (the files to tag) that seems like it would work. so i start with the sheet selected, form the array, then ask the user to select the files to be tagged, and it uses the array to tag?

is that doable?

Does your .csv have the name of the documents? (For quality control, it should.) If so, I would use this flow:

Read a line of the .csv
– parse the tags field(s), store into a list variable
– parse the filename
Search DEVONthink for a file with that name [searching can be scripted]
If found
– set the tags of that record with the tags currently in the list variable
if not found
– write an error to the log [logging can be scripted]
Repeat

Alternately, you could just read the whole .csv into a list of records with properties {document name, tags} and then run through the list record-by-record.

Since a document cannot have the same tag assigned more than once – if you try, DEVONthink will merely ignore you – there’s no risk if the script fails or you run it more than once, or you’re just testing with it. I.e., no need, IMO, to break this down into smaller jobs; no need to have a single script for each folder (unless there is a characteristic of your data not mentioned above).

Maybe someone else will write the code for you, or maybe you could.

yeah, the filename is the first entry in the sheet essentially.

my example looks like this:

Thanks. Should be an easy script for you, then.