|
|
AppleScript: Simple list of titles
|
|
|
|
Dedicated MacNNer
Join Date: Jun 2006
Status:
Offline
|
|
After yet another user asking me for a way to print a simple list of titles from Delicious Library I whipped up an AppleScript to create a title list. Feel free to adapt it for your own use, and if you are an AppleScript guru, feel free to add your corrections.
set pathToXMLFile to POSIX path of ((path to application support from user domain) & "Delicious Library:Library Media Data.xml" as string)
tell application "System Events" tell contents of XML file pathToXMLFile-- Get selected shelf element
set rootElement to first XML element
set shelvesElement to a reference to XML element "shelves" of rootElement
set shelfNames to value of XML attribute "name" of every XML element of shelvesElement
set selectedShelfName to (choose from list shelfNames with prompt "Select a shelf:" without multiple selections allowed) as text
set selectedShelfElement to a reference to (first XML element of shelvesElement where the value of its XML attribute "name" is selectedShelfName)
-- For each shelf item, find the matching medium and write out its title
set shelfElements to a reference to XML elements of selectedShelfElement
set itemElements to a reference to XML element "items" of rootElement
set pathToTextFile to choose file name
set textFile to open for access pathToTextFile with write permission
set eof textFile to 0 -- clear file just in case
repeat with shelfElement in shelfElementstryset mediumUUID to value of XML attribute "uuid" of shelfElement
set itemElement to (a reference to (first XML element of itemElements where the value of its XML attribute "uuid" is mediumUUID))
set itemTitle to value of XML attribute "title" of itemElement
write itemTitle & return to textFile end try end repeat
close access textFile
display alert "Done creating title list" as informational giving up after 10 end tell end tell
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|