- The file path is incomplete in the example.
- The filename and the Document Name are not the same here. You can’t set the title of a PDF as it’s read only. However, if the PDF has the title in place, it will be part of the import.
- You need to define what the custom metadata names are.
Here is my sample CSV in DEVONthink…
Here is a simple teaching edition snippet.
set docsPath to "~/Desktop/"
-- I am using this variable as your example text showed an incomplete path.
-- Using the variable above would import from files on my desktop.
-- Using a full path in the CSV could supersede this method.
tell application id "DNtp"
set doc to (item 1 of (selection as list)) -- Handling a csv file selected in DEVONthink
-- Get the header names and set variables for the meta data names
set docHeaders to (columns of doc)
set md1 to (item 2 of docHeaders) as string
set md2 to (item 3 of docHeaders) as string
set docContents to (cells of doc) -- Get the contents of the cells in the file
repeat with csvItem in docContents
set newRecord to import (docsPath & (item 1 of csvItem)) to current group -- Import the file
-- Add the custom metadata
add custom meta data (item 2 of csvItem) for md1 to newRecord
add custom meta data (item 3 of csvItem) for md2 to newRecord
end repeat
end tell