Thank you to everyone who shared their ideas and experiences. Multiple working
answers, which is great.
***All involved: May I please include your answers, crediting you of course,
in my github repository of useful scripts for BibDesk
(https://github.com/ghoetker/BibDeskAppleScripts
<https://github.com/ghoetker/BibDeskAppleScripts>), linked to from the wiki?
Future users might find having the answers consolidated to be useful.***
I’ve modified Roberto’s answer to suit my particular need. The following shell
script consumes a base64-encoded binary plist, which is what is represented in
the Bdsk-File-N field (e.g.,” YnBsaXN0MDDUAQIDBAUGJ…AAAAAAqc=”) and emits the
xml-encoded (human-readable) plist to the standard output.
```
#!/bin/bash
# Thanks to Roberto on the Bibdesk-users mailing list, who drew
# inspiration from https://github.com/foice/BibDesk2Zotero_attachments
<https://github.com/foice/BibDesk2Zotero_attachments>
# Usage
# dealias ABC
# where ABC is the base64 encoded string included in the Bdsk-File-N field
# It will emit the corresponding xml-encoded (human readable) plist
# to the standard output for your further processing pleasure.
echo "$1" | base64 -D | plutil -convert xml1 -o - -- -
```
So, it differs from Roberto’s in not creating any files as final output or
intermediate steps. For my specific application that’s great, as I can
grep or sed my .bib file to grab just the Bdsk-File-N fields
pipe that through sed to remove everything but the actual base64 string
pipe that through dealias to emit the xml-formatted plist
pipe that through a xml-parser to extract the information I want
Not having to create intermediate files for all 7000+ publications in my
database (yes, yes, I know…) will be a convenience and possible speed savings.
For some other applications, Roberto’s approach would work better.
Thank you again to everyone who offered solutions. I learned a great deal!
Glenn
For clarity and as a test, if you save the shell script as dealias somewhere
your system can find it and invoked with
dealias
YnBsaXN0MDDUAQIDBAUGJCVYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoKgHCBMUFRYaIVUkbnVsbNMJCgsMDxJXTlMua2V5c1pOUy5vYmplY3RzViRjbGFzc6INDoACgAOiEBGABIAFgAdccmVsYXRpdmVQYXRoWWFsaWFzRGF0YV8QG0EvQW1lbWl5YS0xOTg0LVRvYml0LTAwLnBkZtIXCxgZV05TLmRhdGFPEQF8AAAAAAF8AAIAAAxNYWNpbnRvc2ggSEQAAAAAAAAAAAAAAAAAAAAAAAAAQkQAAf////8ZQW1lbWl5YS0xOTg0LVRvYml0LTAwLnBkZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAABAAMAAAogY3UAAAAAAAAAAAAAAAAAAUEAAAIAOi86VXNlcnM6Z2hvZXRrZXI6QmliRGVza1BhcGVyczpBOkFtZW1peWEtMTk4NC1Ub2JpdC0wMC5wZGYADgA0ABkAQQBtAGUAbQBpAHkAYQAtADEAOQA4ADQALQBUAG8AYgBpAHQALQAwADAALgBwAGQAZgAPABoADABNAGEAYwBpAG4AdABvAHMAaAAgAEgARAASADhVc2Vycy9naG9ldGtlci9CaWJEZXNrUGFwZXJzL0EvQW1lbWl5YS0xOTg0LVRvYml0LTAwLnBkZgATAAEvAAAVAAIAD///AACABtIbHB0eWiRjbGFzc25hbWVYJGNsYXNzZXNdTlNNdXRhYmxlRGF0YaMdHyBWTlNEYXRhWE5TT2JqZWN00hscIiNcTlNEaWN0aW9uYXJ5oiIgXxAPTlNLZXllZEFyY2hpdmVy0SYnVHJvb3SAAQAIABEAGgAjAC0AMgA3AEAARgBNAFUAYABnAGoAbABuAHEAcwB1AHcAhACOAKwAsQC5AjkCOwJAAksCVAJiAmYCbQJ2AnsCiAKLAp0CoAKlAAAAAAAAAgEAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAqc=
it should emit
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"
<http://www.apple.com/DTDs/PropertyList-1.0.dtd%22>>
<plist version="1.0">
<dict>
<key>$archiver</key>
<string>NSKeyedArchiver</string>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
<key>$class</key>
<dict>
<key>CF$UID</key>
<integer>7</integer>
</dict>
<key>NS.keys</key>
<array>
<dict>
<key>CF$UID</key>
<integer>2</integer>
</dict>
<dict>
<key>CF$UID</key>
<integer>3</integer>
</dict>
</array>
<key>NS.objects</key>
<array>
<dict>
<key>CF$UID</key>
<integer>4</integer>
</dict>
<dict>
<key>CF$UID</key>
<integer>5</integer>
</dict>
</array>
</dict>
<string>relativePath</string>
<string>aliasData</string>
<string>A/Amemiya-1984-Tobit-00.pdf</string>
<dict>
<key>$class</key>
<dict>
<key>CF$UID</key>
<integer>6</integer>
</dict>
<key>NS.data</key>
<data>
AAAAAAF8AAIAAAxNYWNpbnRvc2ggSEQAAAAAAAAAAAAAAAAAAAAA
AAAAQkQAAf////8ZQW1lbWl5YS0xOTg0LVRvYml0LTAwLnBkZgAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////
/wAAAAAAAAAAAAAAAAABAAMAAAogY3UAAAAAAAAAAAAAAAAAAUEA
AAIAOi86VXNlcnM6Z2hvZXRrZXI6QmliRGVza1BhcGVyczpBOkFt
ZW1peWEtMTk4NC1Ub2JpdC0wMC5wZGYADgA0ABkAQQBtAGUAbQBp
AHkAYQAtADEAOQA4ADQALQBUAG8AYgBpAHQALQAwADAALgBwAGQA
ZgAPABoADABNAGEAYwBpAG4AdABvAHMAaAAgAEgARAASADhVc2Vy
cy9naG9ldGtlci9CaWJEZXNrUGFwZXJzL0EvQW1lbWl5YS0xOTg0
LVRvYml0LTAwLnBkZgATAAEvAAAVAAIAD///AAA=
</data>
</dict>
<dict>
<key>$classes</key>
<array>
<string>NSMutableData</string>
<string>NSData</string>
<string>NSObject</string>
</array>
<key>$classname</key>
<string>NSMutableData</string>
</dict>
<dict>
<key>$classes</key>
<array>
<string>NSDictionary</string>
<string>NSObject</string>
</array>
<key>$classname</key>
<string>NSDictionary</string>
</dict>
</array>
<key>$top</key>
<dict>
<key>root</key>
<dict>
<key>CF$UID</key>
<integer>1</integer>
</dict>
</dict>
<key>$version</key>
<integer>100000</integer>
</dict>
</plist>
From: Roberto <foice.n...@gmail.com <mailto:foice.n...@gmail.com>>
Reply-To: For general discussion about using BibDesk
<bibdesk-users@lists.sourceforge.net
<mailto:bibdesk-users@lists.sourceforge.net>>
Date: Friday, May 11, 2018 at 12:50 AM
To: For general discussion about using BibDesk
<bibdesk-users@lists.sourceforge.net
<mailto:bibdesk-users@lists.sourceforge.net>>
Subject: Re: [Bibdesk-users] Programmatically interpreting Bdsk-File-N
information
maybe this is useful? <>
#!/bin/bash
# thanks to https://github.com/foice/BibDesk2Zotero_attachments
<https://github.com/foice/BibDesk2Zotero_attachments>
echo "$1" > path.encoded
base64 -D -i path.encoded -o path.dec
cp path.dec "$2".xml
plutil -convert xml1 "$2".xml
it draws from code here
https://github.com/foice/BibDesk2Zotero_attachments
<https://github.com/foice/BibDesk2Zotero_attachments>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users