Thanks! I will give that a try.

> On Nov 17, 2014, at 5:21 AM, Jan Jakob Bornheim <[email protected]> wrote:
> 
> 
>> On 17 Nov, 2014, at 01:26, Christiaan Hofman <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> 
>> On Nov 13, 2014, at 22:55, Jason Tilley wrote:
>> 
>>> I recently switched from JabRef to BibDesk since JabRef is dependent on 
>>> Java and Apple is dependent on making Java a major pain. I would like to 
>>> automatically create cite keys that are in the same style as my existing 
>>> bibliography. Currently my cite keys are like the following examples:
>>> 
>>> 1) McCracken_2004 for a single author
>>> 2) McCracken_and_Maxwell_2004 for two authors
>>> 3) McCracken_et_al_2004 for 3 or more authors
>>> 
>>> The closest I can get to this with a custom cite key format is using the 
>>> string:
>>> 
>>> %a[][_et_al]1_%Y
>>> 
>>> This works for works with one or three or more authors well, but this can’t 
>>> handle instances with 2 authors. Does anyone know how to do this? Is there 
>>> maybe a way to embed an if statement in my format string? Any help with 
>>> this would be greatly appreciated. Thanks.
>> 
>> 
>> No, this level of complexity is not supported.
>> 
>> Christiaan
> 
> My usual answer: You could use AppleScript. It’s not very elegant, nor fast, 
> but it gets the job done.
> 
> Cheers,
> Jan Jakob
> 
> Something like this should get you started:
> 
> tell document 1 of application "BibDesk"
>       
>       set thePubs to selection
>       set theLetters to "abcdefghijklmnopqrstuvwxyz" # these are the unique 
> identifiers added to ambigous cite keys
>       set theUsedCiteKeys to {} # we have to keep track of the cite keys 
> already assigned in this AppleScript run to avoid assigning  the same cite 
> key twice
>       
>       repeat with thePub in thePubs
>               set shouldRepeat to true
>               set i to 1
>               
>               set theAuthors to authors of thePub
>               set theYear to publication year of thePub
>               set theAuthorsCount to (get count of theAuthors)
>               
>               # Determine the cite key format
>               
>               if theAuthorsCount is 1 then
>                       set theGeneratedCiteKey to last name of item 1 of 
> theAuthors & "_" & theYear
>               else if theAuthorsCount is 2 then
>                       set theGeneratedCiteKey to last name of item 1 of 
> theAuthors & "_and_" & last name of item 2 of theAuthors & "_" & theYear
>               else
>                       set theGeneratedCiteKey to last name of item 1 of 
> theAuthors & "_et_al_" & theYear
>               end if
>               
>               # Now let's test whether there is already any publication that 
> has the same cite key or if we have already used the same cite key in this 
> session
>               
>               set the theProvisionalCiteKey to theGeneratedCiteKey
>               
>               repeat while shouldRepeat is true                       
>                       set theOtherPub to get (publications whose cite key is 
> theProvisionalCiteKey)                   
>                       if theOtherPub is {} and theProvisionalCiteKey is not 
> in theUsedCiteKeys then
>                               set shouldRepeat to false
>                       else
>                               set theProvisionalCiteKey to 
> theGeneratedCiteKey & "_" & item i of theLetters
>                               set i to i + 1
>                       end if                  
>               end repeat
>               
>               set theFinalCiteKey to theProvisionalCiteKey
>               
>               # Now we assign the new unique (at least within the thePubs 
> group) cite key
>               
>               set cite key of thePub to theFinalCiteKey
>               set theUsedCiteKeys to theUsedCiteKeys & theFinalCiteKey
>               
>       end repeat
>       
> end tell
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk_______________________________________________
> Bibdesk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to