I am trying to export the formatted references to a text file. I am using a keyword (called "read_it") to filter the entire library and saving the result into a text file. My question is, can I export a smart group (called "group_read_it") that already has the filtered reference using the keyword ("read_it")? searching a keyword in the entire library takes time and slows down the entire process!
I am not sure if one can export the references from a smart filter although few groups like "group recently viewed" does work well, here is my AppleScript that works well to filter the entire library with keyword search
tell application "Bookends"
tell front library window
set myPubs to every publication item whose keywords contains "read_it"
if myPubs is not {} then
set theBody to format myPubs using "read_it" as HTML
end if
end tell
end tell
set outputFile to ((path to desktop as text) & "LaunchAgent_Alert.html") -- represents "MacHD:Users:chittu:Desktop:LaunchAgent_Alert.txt"
try
set fileReference to open for access file outputFile with write permission
write theBody to fileReference
close access fileReference
on error
try
close access file outputFile
end try
end try
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Bookends"
tell front library window
set GroupsList to every group item's name
set the_selection to choose from list GroupsList
if the_selection is false then
error number -128 -- User canceled
else
set groupName to item 1 of the_selection
set myPubs to publication items of group item groupName
end if
if myPubs is not {} then
set theBody to format myPubs using "read_it" as HTML
end if
end tell
end tell
set outputFile to ((path to desktop as text) & "LaunchAgent_Alert.html") -- represents "MacHD:Users:chittu:Desktop:LaunchAgent_Alert.txt"
try
set fileReference to open for access file outputFile with write permission
write theBody to fileReference
close access fileReference
on error
try
close access file outputFile
end try
end try
excellent! this works well. Is it possible to include the name of the smart group (namely "read_it") in the script? current script requires the user's input (choose from the list). I did try myself but I can't get it working.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Bookends"
tell front library window
set GroupName to "read_it"
set myPubs to publication items of group item GroupName
if myPubs is not {} then
set theBody to format myPubs using "read_it" as HTML
end if
end tell
end tell
set outputFile to ((path to desktop as text) & "LaunchAgent_Alert.html") -- represents "MacHD:Users:chittu:Desktop:LaunchAgent_Alert.txt"
try
set fileReference to open for access file outputFile with write permission
write theBody to fileReference
close access fileReference
on error
try
close access file outputFile
end try
end try