I rarely leave a script as is more than 5 days so don’t be surprised if I post a new version.
I understood that I may ask the system to make the link between an apple ID and the name of the application.
Given that I was able to allow us to choose among a list of true applications names.
Here I have one case of file which have no available application name so I treat this sort of case but most of us will never see that at work.
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
property |⌘| : a reference to current application
Germaine()
on Germaine()
set begOfPath to (path to application support from user domain as text) & "com.apple.sharedfilelist:"
set begOfPathLong to begOfPath & "com.apple.LSSharedFileList.ApplicationRecentDocuments:"
tell application "Finder" to set theFiles to name of files of folder begOfPathLong
set theApps to {}
repeat with anItem in theFiles
set appID to text 1 thru -6 of anItem
try
set appName to name of (application id appID)
on error
set appName to appID
end try
set end of theApps to appName
end repeat
# I disabled FavoriteVolumes because selecting it urged the system to open numerous dmg files.
set specialCases to {"RecentApplications", "RecentDocuments", "FavoriteItems"} # , "FavoriteVolumes"
set theChoices to specialCases & theApps
set appName to choose from list theChoices
if appName is false then error number -128
set appName to appName's item 1
if appName is in specialCases then
set recentDocumentsPath to POSIX path of (begOfPath & "com.apple.LSSharedFileList." & appName & ".sfl2")
else
repeat with i from 1 to count theApps
if appName = item i of theApps then
set recentDocumentsPath to POSIX path of (begOfPathLong & item i of theFiles)
exit repeat
end if
end repeat
end if
try
set plistData to |⌘|'s NSData's dataWithContentsOfFile:recentDocumentsPath
set recentDocuments to |⌘|'s NSKeyedUnarchiver's unarchiveObjectWithData:plistData
set documentPaths to {}
repeat with aDocument in (recentDocuments's objectForKey:"items")
set documentBookmark to (aDocument's objectForKey:"Bookmark")
set {documentURL, resolveError} to (|⌘|'s NSURL's URLByResolvingBookmarkData:documentBookmark options:0 relativeToURL:(missing value) bookmarkDataIsStale:(missing value) |error|:(reference))
if resolveError is missing value then
set end of documentPaths to documentURL's |path|() as string
end if
end repeat
documentPaths as list
on error
error "The selected application is not treated or has no sfl2 associated file"
end try
end Germaine
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 11 septembre 2019 21:17:06
Hi! I came across this thread because I am looking for a way to parse the recent items of Affinity Designer 2. There seems to be a bug that deletes the items from the sfl2 file. But there is a very similar-looking file located here:
The script in post #9 of this thread doesn’t list the .sfl or .sfl2 file for your application? Are you sure? This file has binary data and your .dat file has text (XML) format.
.dat files are created by applications for use by the application itself and will not be easily decrypted. Especially not having this paid app on your computer. Perhaps one of the experienced users has it to help with the problem.
It does list the file for Affinity Designer 2. But due to a bug that file does not have any recent bookmarks once you quit the application. The bug has been reported several months ago. No fix yet.
Here is the error I get when running the script for the .dat file:
**error** "*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (RecentDocumentInfo) for key (NS.objects) because no class named \"RecentDocumentInfo\" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target). If the class was renamed, use setClassName:forClass: to add a class translation mapping to NSKeyedUnarchiver" number -2700