批量修改(batch editing)zotero字段内容的参考网址:

https://www.zotero.org/support/dev/client_coding/javascript_api#batch_editing 

导入zotero的书籍类型文献记录(ISBN,amazon等网站)的出版社信息可能比较混乱,如下图所示:

 

 

1.点击【tools】-->【Developer】-->【Run Javascript】

 

 

2.在弹出的窗口,复制、粘贴示例程序

https://www.zotero.org/support/dev/client_coding/javascript_api#batch_editing 

Example: Item Field Changes

Edit the first three lines as necessary:

var fieldName = "publicationTitle";
var oldValue = "Foo";
var newValue = "Foo2";
 
var fieldID = Zotero.ItemFields.getID(fieldName);
var s = new Zotero.Search();
s.libraryID = ZoteroPane.getSelectedLibraryID();
s.addCondition(fieldName, 'is', oldValue);
var ids = await s.search();
if (!ids.length) {
    return "No items found";
}
await Zotero.DB.executeTransaction(async function () {
    for (let id of ids) {
        let item = await Zotero.Items.getAsync(id);
        let mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
        item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);
        await item.save();
    }
});
return ids.length + " item(s) updated";


zotero数据库字段列表查看:

https://www.zotero.org/support/dev/client_coding/javascript_api/search_fields

These are the values of the fieldName column in the fields table from system.sql

1

url

 

21

accessDate

 

41

codeNumber

 

61

postType

 

81

documentNumber

2

rights

 

22

seriesTitle

 

42

artworkMedium

 

62

audioFileType

 

82

dateEnacted

3

series

 

23

seriesText

 

43

number

 

63

version

 

83

publicLawNumber

4

volume

 

24

seriesNumber

 

44

artworkSize

 

64

system

 

84

country

5

issue

 

25

institution

 

45

libraryCatalog

 

65

company

 

85

applicationNumber

6

edition

 

26

reportType

 

46

videoRecordingFormat

 

66

conferenceName

 

86

forumTitle

7

place

 

27

code

 

47

interviewMedium

 

67

encyclopediaTitle

 

87

episodeNumber

8

publisher

 

28

session

 

48

letterType

 

68

dictionaryTitle

 

88

blogTitle

9

pages

 

29

legislativeBody

 

49

manuscriptType

 

69

language

 

89

type

10

ISBN

 

30

history

 

50

mapType

 

70

programmingLanguage

 

90

medium

11

publicationTitle

 

31

reporter

 

51

scale

 

71

university

 

91

title

12

ISSN

 

32

court

 

52

thesisType

 

72

abstractNote

 

92

caseName

13

date

 

33

numberOfVolumes

 

53

websiteType

 

73

websiteTitle

 

93

nameOfAct

14

section

 

34

committee

 

54

audioRecordingFormat

 

74

reportNumber

 

94

subject

15

callNumber

 

35

assignee

 

55

label

 

75

billNumber

 

95

proceedingsTitle

16

archiveLocation

 

36

patentNumber

 

56

presentationType

 

76

codeVolume

 

96

bookTitle

17

distributor

 

37

priorityNumbers

 

57

meetingName

 

77

codePages

 

97

shortTitle

18

extra

 

38

issueDate

 

58

studio

 

78

dateDecided

 

98

docketNumber

19

journalAbbreviation

 

39

references

 

59

runningTime

 

79

reporterVolume

 

99

numPages

20

DOI

 

40

legalStatus

 

60

network

 

80

firstPage

 

100

programTitle

 

 

 

 

 

 

 

 

 

 

 

 

101

issuingAuthority

 

 

 

 

 

 

 

 

 

 

 

 

102

filingDate

 

 

 

 

 

 

 

 

 

 

 

 

103

genre

 

 

 

 

 

 

 

 

 

 

 

 

104

archive

 

 

3.修改示例程序的前3行

修改查找字段(fieldName)为【publicationTitle

修改查找值(oldValue)为【Springer Netherlands

修改替换值(newValue)为【Springer

 

 

var fieldName = "publicationTitle";

var oldValue = "Springer Netherlands";

var newValue = "Springer";

 

var fieldID = Zotero.ItemFields.getID(fieldName);

var s = new Zotero.Search();

s.libraryID = ZoteroPane.getSelectedLibraryID();

s.addCondition(fieldName, 'is', oldValue);

var ids = await s.search();

if (!ids.length) {

    return "No items found";

}

await Zotero.DB.executeTransaction(async function () {

    for (let id of ids) {

        let item = await Zotero.Items.getAsync(id);

        let mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);

        item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);

        await item.save();

    }

});

return ids.length + " item(s) updated";

 

 

 

4.点击【Run】按钮

 

运行结果显示:查找替换了12