Bibtex - multiple attachments
Hi all,
I'd like to import a bibtex-file into Zotero. The pdf-field contains four entries divided by a linebreak (\n):
pdf = {D:\PDF\1.pdf
D:\PDF\2.pdf
D:\PDF\3.pdf
D:\PDF\4.pdf}
Zotero only imports the last entry. I changed the lines 1630-1636 in the translator (https://www.zotero.org/trac/browser/extension/trunk/translators/BibTeX.js#L1630). In particular I added some for each loops:
Original:
} else if (field == "pdf") {
if (/:\/\//.test(value)) { // a full uri is given
item.attachments = [{url:value, mimeType:"application/pdf", downloadable:true}];
} else { // if no uri is given, assume that it is an absolute path to the PDF
item.attachments = [{url:"file://"+value, mimeType:"application/pdf"}];
}
}
Modification:
Hi all,
I'd like to import a bibtex-file into Zotero. The pdf-field contains four entries divided by a linebreak (\n):
pdf = {D:\PDF\1.pdf
D:\PDF\2.pdf
D:\PDF\3.pdf
D:\PDF\4.pdf}
Zotero only imports the last entry. I changed the lines 1630-1636 in the translator (https://www.zotero.org/trac/browser/extension/trunk/translators/BibTeX.js#L1630). In particular I added some for each loops:
Original:
} else if (field == "pdf") {
if (/:\/\//.test(value)) { // a full uri is given
item.attachments = [{url:value, mimeType:"application/pdf", downloadable:true}];
} else { // if no uri is given, assume that it is an absolute path to the PDF
item.attachments = [{url:"file://"+value, mimeType:"application/pdf"}];
}
}
Modification:
} else if (field == "pdf") {
if (/:\/\//.test(value)) { // a full uri is given
for each (var temp in value.split("\n")) {
item.attachments = [{url:temp, mimeType:"application/pdf", downloadable:true}];
}
} else { // if no uri is given, assume that it is an absolute path to the PDF
for each (var temp in value.split("\n")) {
item.attachments = [{url:"file://"+temp, mimeType:"application/pdf"}];
}
}
}
But this does not work either. Zotero still only imports the last item?
Can anyone solve this problem?
Regards,
Arne
I'd like to import a bibtex-file into Zotero. The pdf-field contains four entries divided by a linebreak (\n):
pdf = {D:\PDF\1.pdf
D:\PDF\2.pdf
D:\PDF\3.pdf
D:\PDF\4.pdf}
Zotero only imports the last entry. I changed the lines 1630-1636 in the translator (https://www.zotero.org/trac/browser/extension/trunk/translators/BibTeX.js#L1630). In particular I added some for each loops:
Original:
} else if (field == "pdf") {
if (/:\/\//.test(value)) { // a full uri is given
item.attachments = [{url:value, mimeType:"application/pdf", downloadable:true}];
} else { // if no uri is given, assume that it is an absolute path to the PDF
item.attachments = [{url:"file://"+value, mimeType:"application/pdf"}];
}
}
Modification:
Hi all,
I'd like to import a bibtex-file into Zotero. The pdf-field contains four entries divided by a linebreak (\n):
pdf = {D:\PDF\1.pdf
D:\PDF\2.pdf
D:\PDF\3.pdf
D:\PDF\4.pdf}
Zotero only imports the last entry. I changed the lines 1630-1636 in the translator (https://www.zotero.org/trac/browser/extension/trunk/translators/BibTeX.js#L1630). In particular I added some for each loops:
Original:
} else if (field == "pdf") {
if (/:\/\//.test(value)) { // a full uri is given
item.attachments = [{url:value, mimeType:"application/pdf", downloadable:true}];
} else { // if no uri is given, assume that it is an absolute path to the PDF
item.attachments = [{url:"file://"+value, mimeType:"application/pdf"}];
}
}
Modification:
} else if (field == "pdf") {
if (/:\/\//.test(value)) { // a full uri is given
for each (var temp in value.split("\n")) {
item.attachments = [{url:temp, mimeType:"application/pdf", downloadable:true}];
}
} else { // if no uri is given, assume that it is an absolute path to the PDF
for each (var temp in value.split("\n")) {
item.attachments = [{url:"file://"+temp, mimeType:"application/pdf"}];
}
}
}
But this does not work either. Zotero still only imports the last item?
Can anyone solve this problem?
Regards,
Arne
This is an old discussion that has not been active in a long time. Instead of commenting here, you should start a new discussion. If you think the content of this discussion is still relevant, you can link to it from your new discussion.
item.attachments.push( {url:temp,
Your current code is simply replacing the contents of item.attachments each time, rather than adding more elements to the array.mimeType:"application/pdf", downloadable:true} );
item.attachments.push is what I needed!
Unfortunately, this rises another problem: value.split("\n") does not work whereas comma-seperated pdfs do work ( value.split(",") ). As I am using the Bibtex export with EndNote, it does only support seperated attachments by linebreak.
Regards,
Arne
P.S.: How do you do text-highlighting?