AppleScript to reveal BibDesk cache files in Finder

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

AppleScript to reveal BibDesk cache files in Finder

slow down
Here's an AppleScript that I use for BibDesk-Journler integration. Please post
it to the wiki if you think it would be useful to others!

(*
This script reveals in a Finder window the BibDesk metadata cache files of the
publications selected in the front document. Hence, it should be run after your
BibTeX document has been saved in BibDesk and the metadata cache files have been
automatically written to disk. Opening any of these cache files will select the
corresponding publications in the BibDesk document. This is how I use the script
in my workflow: While writing in Journler, when I want to link to a publication
in BibDesk, I switch to BibDesk and I select the publications to which I want to
link. Then I run this script. Then I drag the selected files into my Journler
text, where they appear as hyperlinked cite keys. Henceforth, clicking on any of
the cite keys in the Journler text automatically selects the publication in
BibDesk.
*)

tellapplication"BibDesk"
--without document, there is no selection, so nothing to do
if(countofdocuments) = 0 then
beep
display dialog"No documents found." buttons{"•"} default button1 giving up
after3
endif
setthePublicationstoselectionofdocument1
endtell
setlistOfPathsto{}
repeatwiththePubinthePublications
tellapplication"BibDesk"
--get the cite key of the selected document and parse it into a bdskcache
filename; assumes standard BibDesk cite key format with one colon, i.e.
"thePrefix:theSuffix"
settheCiteKeytothecite keyofthePubasstring
setthePrefixtotext1 thru((offsetof":" intheCiteKey) - 1) oftheCiteKey
setthePrefixtothePrefixasstring
settheSuffixtotext((offsetof":" intheCiteKey) + 1) thru-1 oftheCiteKey
settheSuffixtotheSuffixasstring
set theCachePath to (path to home folder as text) &
"Library:Caches:Metadata:edu.ucsd.cs.mmccrack.bibdesk:" & thePrefix & "/" &
theSuffix & ".bdskcache"
settheCachePathtotheCachePathasalias
copytheCachePathasaliastotheendoflistOfPaths
endtell
endrepeat
tellapplication"Finder" toreveallistOfPaths



------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Bibdesk-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reveal Cache Files In Finder.scpt.zip (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: AppleScript to reveal BibDesk cache files in Finder

Januz
Hi,

Thank you very much for this script. It works with DEVONthink, too... One thing, though: I had to erase

"/" & theSuffix

from the line

set theCachePath to (path to home folder as text) & "Library:Caches:Metadata:edu.ucsd.cs.mmccrack.bibdesk:" & thePrefix & "/" & theSuffix & ".bdskcache"

to get it to work. It seems that your /Library/Caches/Metadata/edu.ucsd...-folder has folders inside named with the citekeys and in that folders are the cache files?! My cache files just lie in the edu.ucsd...-folder...

Thanks again and all the best,

Januz

Am 07.08.2010 um 06:21 schrieb slow down:

> Here's an AppleScript that I use for BibDesk-Journler integration. Please post
> it to the wiki if you think it would be useful to others!
>
> (*
> This script reveals in a Finder window the BibDesk metadata cache files of the
> publications selected in the front document. Hence, it should be run after your
> BibTeX document has been saved in BibDesk and the metadata cache files have been
> automatically written to disk. Opening any of these cache files will select the
> corresponding publications in the BibDesk document. This is how I use the script
> in my workflow: While writing in Journler, when I want to link to a publication
> in BibDesk, I switch to BibDesk and I select the publications to which I want to
> link. Then I run this script. Then I drag the selected files into my Journler
> text, where they appear as hyperlinked cite keys. Henceforth, clicking on any of
> the cite keys in the Journler text automatically selects the publication in
> BibDesk.
> *)
>
> tellapplication"BibDesk"
> --without document, there is no selection, so nothing to do
> if(countofdocuments) = 0 then
> beep
> display dialog"No documents found." buttons{"•"} default button1 giving up
> after3
> endif
> setthePublicationstoselectionofdocument1
> endtell
> setlistOfPathsto{}
> repeatwiththePubinthePublications
> tellapplication"BibDesk"
> --get the cite key of the selected document and parse it into a bdskcache
> filename; assumes standard BibDesk cite key format with one colon, i.e.
> "thePrefix:theSuffix"
> settheCiteKeytothecite keyofthePubasstring
> setthePrefixtotext1 thru((offsetof":" intheCiteKey) - 1) oftheCiteKey
> setthePrefixtothePrefixasstring
> settheSuffixtotext((offsetof":" intheCiteKey) + 1) thru-1 oftheCiteKey
> settheSuffixtotheSuffixasstring
> set theCachePath to (path to home folder as text) &
> "Library:Caches:Metadata:edu.ucsd.cs.mmccrack.bibdesk:" & thePrefix & "/" &
> theSuffix & ".bdskcache"
> settheCachePathtotheCachePathasalias
> copytheCachePathasaliastotheendoflistOfPaths
> endtell
> endrepeat
> tellapplication"Finder" toreveallistOfPaths
>
>
> <Reveal Cache Files In Finder.scpt.zip>------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev _______________________________________________
> Bibdesk-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users


------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Bibdesk-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users
Reply | Threaded
Open this post in threaded view
|

Re: AppleScript to reveal BibDesk cache files in Finder

slow down
In reply to this post by slow down
I'm glad this script is helpful for you with some modifications.

As I note in the script, the script assumes a cite key in format
thePrefix:theSuffix (for example, First Author + : + Year + 2 Unique Letters, or
Smith:2007ya, which is the default in my version of BibDesk). If your cite keys
have a different format (for example, Sci:Smith:2007ya or Smith2007ya), you will
have to edit the script so that it works with your cite keys.

Because the Mac OS path delimiter is ":" (rather than the POSIX delimiter "/"),
a cite key in format Smith:2007ya has a metadata cache file with the Mac OS
filename "Smith/2007ya.bdskcache" (at least, this is true in Mac OS X 10.4,
which I am using). The part of the script that did not work for you is devoted
to dealing with the Mac OS treatment of colons in filenames.

Best wishes!

At 2010-08-07 14:31 Janosch Linkersdörfer wrote:

> Hi,
>
> Thank you very much for this script. It works with DEVONthink, too...
> One thing, though: I had to erase
>
> "/" & theSuffix
>
> from the line
>
> set theCachePath to (path to home folder as text) &
> "Library:Caches:Metadata:edu.ucsd.cs.mmccrack.bibdesk:" & thePrefix &
> "/" & theSuffix & ".bdskcache"
>
> to get it to work. It seems that your
> /Library/Caches/Metadata/edu.ucsd...-folder has folders inside named
> with the citekeys and in that folders are the cache files?! My cache
> files just lie in the edu.ucsd...-folder...
>
> Thanks again and all the best,
>
> Januz
>
> Am 07.08.2010 um 06:21 schrieb slow down:
>
> > Here's an AppleScript that I use for BibDesk-Journler integration.
> > Please post it to the wiki if you think it would be useful to others!
> >
> > (*
> > This script reveals in a Finder window the BibDesk metadata cache files
> > of the publications selected in the front document. Hence, it should be
> > run after your BibTeX document has been saved in BibDesk and the
> > metadata cache files have been automatically written to disk. Opening
> > any of these cache files will select the corresponding publications in
> > the BibDesk document. This is how I use the script in my workflow: While
> > writing in Journler, when I want to link to a publication in BibDesk, I
> > switch to BibDesk and I select the publications to which I want to link.
> > Then I run this script. Then I drag the selected files into my Journler
> > text, where they appear as hyperlinked cite keys. Henceforth, clicking
> > on any of the cite keys in the Journler text automatically selects the
> > publication in BibDesk.
> > *)
> >
> > tell application "BibDesk"
> > -- without document, there is no selection, so nothing to do
> > if (count of documents) = 0 then
> > beep
> > display dialog "No documents found." buttons {"•"} default button 1
> > giving up after 3
> > end if
> > set thePublications to selection of document 1
> > end tell
> > set listOfPaths to {}
> > repeat with thePub in thePublications
> > tell application "BibDesk"
> > -- get the cite key of the selected document and parse it into a
> > bdskcache filename; assumes standard BibDesk cite key format with one
> > colon, i.e. "thePrefix:theSuffix"
> > set theCiteKey to the cite key of thePub as string
> > set thePrefix to text 1 thru ((offset of ":" in theCiteKey) - 1) of
> > theCiteKey
> > set thePrefix to thePrefix as string
> > set theSuffix to text ((offset of ":" in theCiteKey) + 1) thru -1 of
> > theCiteKey
> > set theSuffix to theSuffix as string
> > set theCachePath to (path to home folder as text) &
> > "Library:Caches:Metadata:edu.ucsd.cs.mmccrack.bibdesk:" & thePrefix &
> > "/" & theSuffix & ".bdskcache"
> > set theCachePath to theCachePath as alias
> > copy theCachePath as alias to the end of listOfPaths
> > end tell
> > end repeat
> > tell application "Finder"
> > reveal listOfPaths
> > activate
> > end tell



     

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Bibdesk-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users
Reply | Threaded
Open this post in threaded view
|

Re: AppleScript to reveal BibDesk cache files in Finder

Adam R. Maxwell
In reply to this post by slow down

On Aug 6, 2010, at 9:21 PM, slow down wrote:

> Here's an AppleScript that I use for BibDesk-Journler integration. Please post
> it to the wiki if you think it would be useful to others!

Please don't rely on the Spotlight cache files for any purpose.  Their location, format, and function should be considered private and subject to change at any time.

I think Christiaan added a URL scheme for linking to items, and that would be a much more reliable solution if you're looking for a way to store links to publications.

thanks,
Adam


------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Bibdesk-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users
Reply | Threaded
Open this post in threaded view
|

Re: AppleScript to reveal BibDesk cache files in Finder

slow down
Sorry, I didn't know about the x-bdsk URL scheme. (Just link to
x-bdsk://citekey in any document.)

You're right, my script is a bad idea. I wish I had known about the URL scheme
before.

I hope this will serve to prevent somebody else from making my mistake.

Stay away from the cache files, folks!

Thanks!

At 2010-08-07 17:09 Adam R. Maxwell wrote:

> On Aug 6, 2010, at 9:21 PM, slow down wrote:
>
> > Here's an AppleScript that I use for BibDesk-Journler integration. Please
>post
> > it to the wiki if you think it would be useful to others!
>
> Please don't rely on the Spotlight cache files for any purpose. Their
> location, format, and function should be considered private and subject
> to change at any time.
>
> I think Christiaan added a URL scheme for linking to items, and that
> would be a much more reliable solution if you're looking for a way to
> store links to publications.
>
> thanks,
> Adam



     

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Bibdesk-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users