I am using DEVONThink quite a while, but I would not call myself an expert, so hopefully my question has not been answered in another topic…
I created a folder containing different intelligent groups, collecting documents with a certain tag within those different groups.
I now would like to export the parent folder to my filesystem, having those intelligent groups each as a subfolder with the collected documents inside.
How is that done?
When I select all intelligent groups and use “export → files and folder…” (as I am using the German locale it’s “Exportieren → Dateien und Ordner…”) the file structure is created in my filesystem, but it contains no documents.
A smart group doesn’t contain anything, so an export would only create an empty Finder folder.
You can manually select the results of a smart group and use File > Export > Files & Folders, exporting them to a specific Finder folder.
Development would have to assess changing the behavior of the export command with a smart group.
The other option is scripting. Here’s a simple script…
(* Exports selected smart groups to a Finder folder. Folder existence is validated; created if not extant.
If run subsequent times, duplicates will be exported for document already exported. *)
tell application id "DNtp"
if selection is {} then return
repeat with theRecord in (selected records)
if (class of theRecord is smart group) then -- Only process selected smart groups
set recordName to (name of theRecord) -- Get the name of the smart group
set exportDest to my dest(recordName) -- Check if the folder exists in the Finder, create it if not
repeat with theChild in (children of theRecord) -- Export the items (children) in the smart group individually
set fileExport to export record theChild to exportDest
end repeat
end if
end repeat
end tell
on dest(recordName)
tell application "Finder"
try
set exportDest to (alias ((path to downloads folder as string) & recordName as string)) -- Does the folder exist in the finder
on error
set exportDest to make new folder at (path to downloads folder) with properties {name:recordName} -- If not, create it
end try
return (POSIX path of (exportDest as alias))
end tell
end dest
Select Script > Compile to ensure it’s compiling properly.
Select File > Save.
In the Save dialog, press Command-Shift-G and paste ~/Library/Application Scripts/com.devon-technologies.think3/Menu. You can save into that directory or a subfolder of your choice.
Give the script your desired name and save it. The script should now be available in the Scripts menu in DEVONthink.
Here is a different version using another approach.
property exportFolder : "~/Downloads/untitled folder 3/" -- You can drag and drop a Finder folder to insert a POSIX path here
tell application id "DNtp"
if selection is {} then return
repeat with theRecord in (selected records)
if (class of theRecord is smart group) then -- Only process selected smart groups
set recordName to (name of theRecord) -- Get the name of the smart group
set exportDest to (exportFolder & recordName as string) -- Folder is created if it doesn't exist
repeat with theChild in (children of theRecord) -- Export the items (children) in the smart group individually
set fileExport to export record theChild to exportDest
end repeat
end if
end repeat
end tell
Yes, but it’s an example of error checking. It’s all too easy to write scripts with a stacked deck, e.g., having a selection made and that line is a good option for people to have in their toolbelt.