How to make use of info from a `file-bookmark` entry in a plist

command linefinderplist

I am trying to create a shell script, or less ideally some AppleScript, that interacts with the folders listed in the Finder’s GoRecent Folders

The contents of this list are stored as an array with the key FXRecentFolders in the Finder’s preferences; i.e., you can get at them like this:
defaults read ~/Library/Preferences/com.apple.finder FXRecentFolders

Ultimately you find file-bookmark types in this array. And I have no idea how in the heck to make heads or tails of their contents. Below is a sample output:

{
    "file-bookmark" = <626f6f6b 64030000 00000410 30000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 48020000 04000000 03030000 00020000 05000000 01010000 55736572 73000000 08000000 01010000 64676f6c 646d616e 09000000 01010000 446f776e 6c6f6164 73000000 0c000000 01060000 10000000 20000000 30000000 08000000 04030000 03d20900 00000000 08000000 04030000 609a0a00 00000000 08000000 04030000 dd671d00 00000000 0c000000 01060000 58000000 68000000 78000000 08000000 00040000 41befdbe 93000000 18000000 01020000 02000000 00000000 0f000000 00000000 00000000 00000000 00000000 01050000 08000000 04030000 01000000 00000000 04000000 03030000 f6010000 08000000 01090000 66696c65 3a2f2f2f 0b000000 01010000 64757374 6f2d6469 736b6f00 08000000 04030000 00604664 3a000000 08000000 00040000 41c08d88 bb5c20ea 24000000 01010000 43324138 35354643 2d384536 342d3438 34312d41 3837382d 43364338 43433931 30444246 18000000 01020000 81000000 01000000 ef130000 01000000 00000000 00000000 01000000 01010000 2f000000 b3000000 01020000 61383137 65633932 63303266 64306461 37353433 34386362 64656162 39363766 35643433 66313530 3b30303b 30303030 30303030 3b303030 30303030 303b3030 30303030 30303b30 30303030 30303030 30303030 3032303b 636f6d2e 6170706c 652e6170 702d7361 6e64626f 782e7265 61642d77 72697465 3b30313b 30313030 30303034 3b303030 30303030 30303031 64363764 643b3031 3b2f7573 6572732f 64676f6c 646d616e 2f646f77 6e6c6f61 64730000 e4000000 feffffff 01000000 00000000 12000000 04100000 44000000 00000000 05100000 88000000 00000000 10100000 ac000000 00000000 40100000 9c000000 00000000 02200000 80010000 00000000 05200000 f0000000 00000000 10200000 00010000 00000000 11200000 34010000 00000000 12200000 14010000 00000000 13200000 24010000 00000000 20200000 60010000 00000000 30200000 cc000000 00000000 01c00000 d4000000 00000000 11c00000 20000000 00000000 12c00000 e4000000 00000000 01d00000 cc000000 00000000 10d00000 04000000 00000000 80f00000 8c010000 00000000>;
    name = Downloads;
}

Are there command line tools, some simple Swift, or anything else I could press into service to help with this task?

Best Answer

The data in file-bookmarks can be converted to an NSURL object. If you know at least a little about macOS programming, you can load this data using the UserDefaults system and parse it back into a path using NSURL's URLByResolvingBookmarkData method.

There is some Objective-C sample code over at StackOverflow that still works on Mojave, reading data from FXRecentFolders and outputting the path to stdout. I am not skilled enough in Swift, but it is probably not difficult to convert that to some equivalent Swift.