Just some examples that hopefully clarify how it works:
- Article example
[journal:unprotect_terms:regex("[{}]",""):truncate1]/[journal:unprotect_terms:regex("[{}]",""):regex(" ","_")]/[YEAR]/___[journal:abbr]_[YEAR].comma._[volume][number:regex(".+", "\.po\.$0\.pc\.")].comma._[firstpage].hyphen.[lastpage]
@Article{M/Molecular_Aspects_of_Medicine/1999/___MAoM_1999.comma._20.po.12.pc…comma._1.hyphen.137,
author = {Julia A Hasler and Ronald Estabrook and Michael Murray and Irina Pikuleva and Michael Waterman and Jorge Capdevila and Vijakumar Holla and Christian Helvig and John R Falck and Geoffrey Farrell and Laurence S Kaminsky and Simon D Spivack and Eric Boitier and Philippe Beaune},
title = {Human cytochromes P450},
date = {1999-02},
issn = {0098-2997},
number = {1-2},
pages = {1–137},
volume = {20},
doi = {10.1016/s0098-2997(99)00005-9},
file = {:Journal/M/Molecular_Aspects_of_Medicine/1999/MAoM 1999, 20(12), 1-137.pdf:PDF},
journaltitle = {Molecular Aspects of Medicine},
keywords = {Cytochrome P450, Xenobiotics, Drug metabolism, Genetic polymorphisms, Steroid hormone synthesis, Fatty acid epoxidation, Eicosaniod metabolism, Disease, Chemical carcinogenesis, Cancer, Autoantibodies},
publisher = {Elsevier {BV}},
url = {https://www.sciencedirect.com/science/article/pii/S0098299799000059
},
}
- Book example
___[booktitle:unprotect_terms:regex("[{}]",""):regex(" ","_")][booksubtitle:unprotect_terms:regex("[{}]",""):regex(" ","_"):regex(".+","_.hyphen._$0")][edition:regex(".+",".comma._$0_ed.")].comma._[YEAR]
@Book{__Drug_Metabolism.hyphen._Current_Concepts.comma._2006,
booktitle = {Drug Metabolism},
editor = {Ionescu, Corina and Caira, Mino R.},
publisher = {SPRINGER NATURE},
booksubtitle = {Current Concepts},
isbn = {1402041411},
title = {Drug Metabolism: Current Concepts},
date = {2006-02},
doi = {10.1007/1-4020-4142-X},
ean = {9781402041419},
file = {:Book/Drug Metabolism - Current Concepts, 2006.pdf:PDF},
pagetotal = {422},
url = {https://www.ebook.de/de/product/5305610/drug_metabolism_current_concepts.html
},
}
- inBook example
___[booktitle:unprotect_terms:regex("[{}]",""):regex(" ","_")][booksubtitle:unprotect_terms:regex("[{}]",""):regex(" ","_"):regex(".+","_.hyphen._$0")][edition:regex(".+",".comma._$0_ed.")][chapter:unprotect_terms:regex("[{}]",""):regex(" ","_"):regex(".+",".comma._ch._$0")].comma._[YEAR].comma._[firstpage].hyphen.[lastpage]
InBook{___The_Organic_Chemistry_of_Drug_Design_and_Drug_Action.comma._ch._7_Drug_Metabolism.comma._1992.comma._277.hyphen.351,
author = {Richard B. Silverman},
booktitle = {The Organic Chemistry of Drug Design and Drug Action},
chapter = {7: Drug Metabolism},
editor = {Richard B. Silverman},
pages = {277–351},
publisher = {Academic Press},
year = {1992},
address = {San Diego},
isbn = {978-0-12-643730-0},
title = {CHAPTER 7: - Drug Metabolism},
doi = {10.1016/B978-0-08-057123-2.50011-9},
file = {:Book/The Organic Chemistry of Drug Design and Drug Action, ch. 7 Drug Metabolism, 1992, 277-351.pdf:PDF},
url = {https://www.sciencedirect.com/science/article/pii/B9780080571232500119
},
}
and for conversion to directory structure and filename:
- directory
[EntryType:regex("InBook","Book"):regex("Article","Journal")]/[citationkey:regex("^(.*)___(.*)$","$1")]
- filename
[citationkey:regex("^(.*)___(.*)$","$2"):regex(".comma.",","):regex(".hyphen.","-"):regex(".po.","\("):regex(".pc.","\)"):regex("_"," ")]
As you can see the path in the file
is derived from the entryKey
(with replacing Article to Journal and InBook to Book) and the citationkey
.
For those that are less experienced with regular expressions the term [citationkey:regex("^(.*)___(.*)$","$1")]
works as follows:
It searches in the citationkey field for anything that matches the definition .*
: any number of characters followed by ___
three underscores followed by .*
: any number of characters.
By default regex stores the matching part of the term in a buffer that can be cited in the replacement term using $0
. In case you want to re-use only a part of the match, you have to define subparts using parentheses. In my example ^(.*)___(.*)$
I have defined two subparts (.*)
before the three underscores and (.*)
after the three underscores. I can cite these in the replacement term with $1
and $2
respectively. $1
I use in the file directory pattern and $2
I use in the filename pattern.
The problem that arises by using the citationkey is that the citation key does not allow to use any character you would like. I have not checked the manual to find out which characters are forbidden in the citationkey, I just used trial and error to find out. To circumvent this issue I used a trick that was used in building the pre-SQL, 7-bit ASCII textfile databases where many characters were not available (7-bit ASCII) and quite a few were reserved for storing instructions to the interpreters of the files. In those systems we used descriptive replacements between two dots for any symbol that was not available or reserved.
So, the citation key contains .comma.
and the filename pattern replaces it with ,
similar for .hyphen., ...