EndnoteToBibTeX.pl

From Organic Design wiki

<perl>

  1. !/usr/bin/perl -w

use strict;

local $/="\}\n\n\n\n";

open(F, "bibex.bib") or die("cannot open file $!");

while(my $record = <F>) {

   # Adding braces to capitalized words
  1. Remove already braced cases
   $record =~ s/\{(DNA)\}/$1/g;  
   $record =~ s/(DNA)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(RNA)\}/$1/g;		
   $record =~ s/(RNA)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(UTR)\}/$1/g;		
   $record =~ s/(UTR)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(SID)\}/$1/g;		
   $record =~ s/(SID)/\{$1\}/g;    
  1. Remove already braced cases
   $record =~ s/\{(FEBS)\}/$1/g;		
   $record =~ s/(FEBS)/\{$1\}/g;    
  1. Remove already braced cases
   $record =~ s/\{(BMC)\}/$1/g;		
   $record =~ s/(BMC)/\{$1\}/g;    
  1. Remove already braced cases
   $record =~ s/\{(ORN)\}/$1/g;		
   $record =~ s/(ORN)/\{$1\}/g;    
  1. Remove already braced cases
   $record =~ s/\{(SDE)\}/$1/g;		
   $record =~ s/(SDE)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(QDE)\}/$1/g;		
   $record =~ s/(QDE)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(PKR)\}/$1/g;		
   $record =~ s/(PKR)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(PTGS)\}/$1/g;		
   $record =~ s/(PTGS)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(CARPEL FACTORY)\}/$1/g;		
   $record =~ s/(CARPEL FACTORY)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(DICER-LIKE)\}/$1/g;		
   $record =~ s/(DICER-LIKE)/\{$1\}/g;
  1. Remove already braced cases
   $record =~ s/\{(G-protein)\}/$1/g;		
   $record =~ s/(G-protein)/\{$1\}/g;
   # Fix records missing a comma '@article{Title'
   if($record =~ m/\@\w+?\{(\w+?)\s+?Author/s) {
   my$author = $1;
   $record =~ s/(\@\w+?\{$author)/$1\,/g;
   }
   # Fix records that have no author:date label
   if($record =~ m/\@\w+?\{\s+?Author\s*=\s*\{(\w+?),.+?Year\s*=\s*\{(\d+)/s) {
   my($author, $date) = ($1, $2); 
   $record =~ s/(\@\w+?)\{/$1\{$author$date,/;
   }
   print "$record";

}

close(F); </perl>