On 26 Jan 2009, at 5:29 PM, Mark Moll wrote:

> The PubMed search and import functionality in BibDesk is great, but it
> creates a large number of "bogus" fields. It also appends a period to
> the end of the title and the year field is sometimes used as a date
> field. I wrote a little AppleScript to clean up imported entries. I
> know next to nothing about AppleScript, so I'm open to suggestions for
> improvement. Right now I run the script by selecting it from the
> scripts menu, but ideally it'd be run on every reference I import from
> PubMed. Any ideas?
>
> --  
> Mark

Note that this is mostly PubMed, not BibDesk, doing all this. BibDesk  
won't drop fields it gets from PubMed. The Data field is set precisely  
to preserve the full information in the PubMed date.

If you want to automatically run the script after an import, you could  
rewrite it to a script hook. Have a look at the online Help and the  
samples on the Wiki to get an idea how to do this; if you don't need  
that you could safely remove it, because bibtex doesn't use it.

Perhaps a simplification of your script is to define a property for  
all the fields you want to clear and then run a repeat loop over them.

Christiaan

> CleanPubmed.scpt:
> ---------------------------------------------------------------
> tell application "BibDesk"
>       if (count of documents) = 0 then
>               return
>       end if
>       set thePublications to selection of document 1
>       repeat with thePub in thePublications
>               -- remove period at end of title
>               set theTitle to title of thePub
>               if item -1 of theTitle = "." then
>                       set theTitle to items 1 thru -2 of theTitle as text
>               end if
>               
>               tell thePub
>                       set value of field "Title" to theTitle
>                       -- change values of the form "2009 Jan 1" to "2009"
>                       set theDate to get value of field "Year"
>                       set value of field "Year" to word 1 of theDate
>                       -- remove bogus fields
>                       set value of field "Address" to ""
>                       set value of field "Au" to ""
>                       set value of field "Crdt" to ""
>                       set value of field "Da" to ""
>                       set value of field "Dcom" to ""
>                       set value of field "Dep" to ""
>                       set value of field "Edat" to ""
>                       set value of field "Gr" to ""
>                       set value of field "Issn" to ""
>                       set value of field "Jid" to ""
>                       set value of field "Jt" to ""
>                       set value of field "Language" to ""
>                       set value of field "Lr" to ""
>                       set value of field "Mh" to ""
>                       set value of field "Mhda" to ""
>                       set value of field "Oid" to ""
>                       set value of field "Own" to ""
>                       set value of field "Phst" to ""
>                       set value of field "Pii" to ""
>                       set value of field "Pl" to ""
>                       set value of field "Pst" to ""
>                       set value of field "Pt" to ""
>                       set value of field "Rf" to ""
>                       set value of field "Rn" to ""
>                       set value of field "Sb" to ""
>                       set value of field "So" to ""
>                       set value of field "Stat" to ""
>               end tell
>       end repeat
> end tell


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to