Artikel-Schlagworte: „mendeley“

Abbreviated Journal Names with Mendeley - Replace Long Journal Names Automatically

Freitag, 11. Dezember 2009

I created a small bash script that replaces the full journal names with the abbreviated ones (MEDLINE-standard).
You need to download the list of journals from pubmed and place it within the same folder of the script.

Additionally you need sqlite3 (sudo apt-get install sqlite3) under Ubuntu Linux. On Windows systems you need to install cygwin or something similar first i think… but it easier to make the conversion on a linux box on the campus.

Then you should adjust the path to your database file according to your operating system:

  • Windows XP: C:\Documents and Settings\<Your Name>\Local Settings\Application Data\Mendeley Ltd\Mendeley Desktop\
  • Windows Vista / Windows 7: %LOCALAPPDATA%\Mendeley Ltd.\Mendeley Desktop\
  • Mac OS X: /Users/<Your username>/Library/Application Support/Mendeley Desktop/
  • Linux: ~/.local/share/data/Mendeley Ltd./Mendeley Desktop/

After you have done so, I recommend running the script once in echo only mode. If the result looks okay, change the last echo to sqlite3 $db.

Please feel free to leave comments…

Good look ;)
#!/bin/bash
db=test.sqlite # set the db-file here. The location depends on the OS you use.
limit="WHERE confirmed='true' AND type='JournalArticle'"
sqlite3 $db "SELECT id FROM Documents $limit" > temp_ids.txt
cat temp_ids.txt | while read line
do
long=$(sqlite3 $db "SELECT publication FROM Documents WHERE id=$line")
echo "long = $long"
#echo "The id is $line"
line_pubm=$(grep -i -n -m 1 "$long" J_Medline.txt | cut -f1 -d:)
#echo "linenumber in pubm= $line_pubm"
abbr_linen=$(( $line_pubm + 1 ))
short=$(sed -n ${abbr_linen}p J_Medline.txt | sed 's/MedAbbr: //' | tr -cd '[:alnum:]‘)
echo “short= $short”
LEN=$(echo ${#short})
echo $LEN
if [ "$short" ]; then
echo “UPDATE Documents SET publication=’$short’ WHERE id=$line”
# sqlite3 $db
# make a security update of your sqlite-file and replace the echo from above with sqlite3 $db
else
echo “no or short shortname (<3 chars) - not changed”
fi
done