File: isi2bib

package info (click to toggle)
cb2bib 2.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,584 kB
  • sloc: cpp: 28,329; sh: 516; makefile: 10
file content (100 lines) | stat: -rwxr-xr-x 2,789 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
#-------------------------------------------------------------------------------
# isi2bib  --  Script to convert ISI format to BibTeX
# cb2Bib Tools
#
# Copyright (C) 2005-2024 by Pere Constans
# constans@molspaces.com
#
# Improvements and modifications:
# Copyright (C) 2009 by Filippo Rusconi
# rusconi@mnhn.fr
#
# May/June 2009:
# - Added checks to ensure that the used commands are available on
#   system.
# - Make use of mktemp to create a temp directory.
#
# See LICENSE file that comes with this distribution
#
# Usage: isi2bib input_isi output_bib
#-------------------------------------------------------------------------------
# Using isi2xml and xml2bib utilities from:
# http://bibutils.refbase.org/
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
# Init variables
#-------------------------------------------------------------------------------
# Modify accordingly
#isi2xml=/usr/local/bin/isi2xml
#xml2bib=/usr/local/bin/xml2bib
isi2xml=isi2xml
xml2bib=xml2bib
isi2xml_flags="-u"
xml2bib_flags="-sd -b"
#-------------------------------------------------------------------------------

# Immediately check that the needed programs are there:
"${isi2xml}" --version > /dev/null 2>&1

if [ "$?" != "0" ]
then
    echo "Program ris2xml (suite bibutils) is required."
    echo "Set it in your path, and/or modify $0 accordingly."
    echo "Ending processing."
    exit 1
fi

"${xml2bib}" --version > /dev/null 2>&1

if [ "$?" != "0" ]
then
    echo "Program xml2bib (suite bibutils) is required."
    echo "Set it in your path, and/or modify $0 accordingly."
    echo "Ending processing."
    exit 1
fi

# Make sure we trap errors (we put that after the tests above because
# we need the tests to fail, in case, without exiting immediately).
set -e

# Getting filenames from command line
echo "cb2Bib Tools: Script to convert ISI format to BibTeX"
echo ""
echo "It uses external package bibutils from"
echo "http://bibutils.refbase.org/"
echo ""
if test "$#" != 2; then
    cat <<EOF
Usage: $0 input_isi output_bib
EOF
    exit 2
fi

# Create temporary directory
# Note that we use the mktemp utility that ensures that
# we do not overwrite any preexisting directory
tmp_dir=$(mktemp -d --tmpdir c2b_tools_tmp.XXXXXXXX)

# Setting files
isi="$1"
bib="$2"
work_dir="$PWD"

# Preparing temporary files
cp "$isi" "${tmp_dir}"/c2b_tmp.isi
cp "$isi" "${tmp_dir}"/c2b_tmp.bib

# bibutils procedure
cd "${tmp_dir}"
"${isi2xml}" $isi2xml_flags c2b_tmp.isi > c2b_tmp.xml
"${xml2bib}" $xml2bib_flags c2b_tmp.xml | sed 's%^ISSUE=%NUMBER=%g' > c2b_tmp.bib

# Clean up
cd "${work_dir}"
cp "${tmp_dir}"/c2b_tmp.bib "$bib"
rm -rf "${tmp_dir}"
echo ""
echo "$0 ended."