TransWikia.com

convert cite keys to lower case

TeX - LaTeX Asked by mchlmchl on May 12, 2021

I’d like to convert all cite keys in a large bibtex file to lower case. I tried to modify the "Downcase Titles" apple script in bibdesk, but I can’t even get the original script to work. When I select a reference and run the script it returns the apple script error "(null)". Do I need to install any dependencies before I can run that script?

Assuming that I can get ‘Downcase Titles’ to work, can I just substitute the two instances of title with cite key in the following line to get it to convert the cite keys then?

set title of thePub to uncapitalize(title of thePub)

If there’s a different way to convert cite keys in a .bib file, that would be fine too, it doesn’t have to be bibdesk, this is a one-off need

One Answer

if sample.bib is

@inproceedings{Zaaaa,
  title = {zzzz}
  booktitle = {Zzzz zzz }
  author = {foo,bar and ggg}
  date = {2000},
  pages = {13--1},
}

@misc{ABC,
  title = {zzzz}
  booktitle = {Zzzz zzz }
  author = {foo,bar and ggg}
  date = {2000},
  pages = {13--1},
}

@book{Zaabha,
  title = {zzzz}
  booktitle = {Zzzz zzz }
  author = {foo,bar and ggg}
  date = {2000},
  pages = {13--1},
}

then the following call to sed on the commandline produces:

$ sed  -e 's/(@[a-zA-Z]*{)([^,]*),/1L2,/'  sample.bib 
@inproceedings{zaaaa,
  title = {zzzz}
  booktitle = {Zzzz zzz }
  author = {foo,bar and ggg}
  date = {2000},
  pages = {13--1},
}

@misc{abc,
  title = {zzzz}
  booktitle = {Zzzz zzz }
  author = {foo,bar and ggg}
  date = {2000},
  pages = {13--1},
}

@book{zaabha,
  title = {zzzz}
  booktitle = {Zzzz zzz }
  author = {foo,bar and ggg}
  date = {2000},
  pages = {13--1},
}

The above is using Gnu Sed, you may prefer to use perl to get the same output

perl  -pe 's/(@[a-zA-Z0-9:]*{)([^,]*),/$1L$2,/'  sample.bib 

Note the above just alters the main keys for each entry If there are internal cross references within the bib file you will want to lowercase those as well to keep the bib file being consistent, something like

sed -e 's/(scrossref = )({[A-Za-z0-9:]*})/1L2/' sample.bib

Correct answer by David Carlisle on May 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP