File renaming, camel-case: why isn't the first character a capital ?
Hello,
File renaming in Zotero 7.0 works fine for me. Many thanks for the great efforts already done !
I want to use in the filename-template the case = "camel". It works but I'm wondering why the lower camel case (ex. "thisIsAStrangeString") is preferred above the upper camel case (ex. "ThisIsALessStrangeString") ?
Is it just a matter of my bad taste ;-) ?
Is it somehow possible to get the upper camel case for a variable in the filename-template ?
Jan
File renaming in Zotero 7.0 works fine for me. Many thanks for the great efforts already done !
I want to use in the filename-template the case = "camel". It works but I'm wondering why the lower camel case (ex. "thisIsAStrangeString") is preferred above the upper camel case (ex. "ThisIsALessStrangeString") ?
Is it just a matter of my bad taste ;-) ?
Is it somehow possible to get the upper camel case for a variable in the filename-template ?
Jan
I'd think it wouldn't be hard to add PascalCase as an option for the case attribute in rename, but I'd guess devs would want to see some demand for this.
Javascript regex doesn't recognize the \u modifier -- otherwise you could easily do this with a replace function -- but at least on quick testing, this works for me, though I'm not clear why:{{ title case="camel" truncate="100" replaceFrom="^(\w)" replaceTo="\$1" }}
{{ title case="camel" truncate="100" replaceFrom="^(\w)" replaceTo="\$1" }}
This works because
\
in thereplaceTo
is taken as the literal value, and$1
is used to specify the capturing groupยน. In other words, this regex replaces the first "word character" with the same character, prefixed with a backslash. For example, "Lorem Ipsum" becomes "\Lorem Ipsum". This is later processed by the case-sentencing logic, converting it to "\LoremIpsum" (first character is lower-cased but here it's "\" so it remains the same). In the final stage, when characters that are not safe for use in file names are removed, it becomes "LoremIpsum".So it works, but in a confusing way, I'd not use this solution. We can consider adding support for "pascal" case.
Thank you very much for the quick answers ! I will try out the suggested work-around (smart one) and explaination. Because I needed already a replaceFrom - replaceTo for other reasons (ex. replaceFrom="\se\.a\.$" replaceTo="_etal" ), it will still be a bit of a puzzle ;-)