# Filename format pattern (novice user)

**URL:** <https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872>\
**Category:** Help\
**Created:** [July 29, 2021, 9:24am UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872 "2021-07-29T09:24:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggieling](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@ggieling](https://discourse.jabref.org/u/ggieling)\
**Post date:** [July 29, 2021, 9:24am UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/1 "2021-07-29T09:24:25Z")

</div>

I am testing JabRef to see if it is a viable option as an index for maintaining a large collection of scientific journal publications (currently 45.000 pdf files).

Part of the functionality I intend to use is to automatically structure the file locations and filenames of the saved pdf files.  
The database is set to biblatex mode.  
The filename format pattern is: [journal] [YEAR], [volume][number:regex(".+", “($0)”)], [firstpage]-[lastpage]  
The example file carries as journal title: {ACS} Medicinal Chemistry Letters

In the resulting filename the curly braces are replaced with underscores (e.g. _ACS_ Medicinal Chemistry Letters 2013, 4(5), 491-496.pdf).  
How do I get rid of these underscores? I prefer to do the correction in the [journal] field over a correction to the entire filename.

I tried `:regex("_","")`, `:regex("\\_","")`,` :regex("{","")`,` :remove_braces`, `:latex_cleanup` but none of these options changes anything to the resulting filename.

---

<div class="post-metadata">

**Author:** ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)\
**Post date:** [July 29, 2021, 7:24pm UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/2 "2021-07-29T19:24:08Z")

</div>

> [@ggieling](#):
>
> How do I get rid of these underscores? I prefer to do the correction in the [journal] field over a correction to the entire filename.

Hi,  
I looked a bit into the issue and tried to come up with a solution. The key problem here is that JabRef interprets the curly braces as protected term and does not replace them. That’s why the regex formatter has no effect. So the curly braces stay the same.  
Remove braces only works for braces at the start and at the end of the whole field content.  
The underscores are coming from the file name generator, because curly braces are illegal characters in file names, they are replaced with underscores. However, this happens after the evacuation of the bracketed patttern

Maybe @k3KAW8Pnf7mkmdSMPHz2 has another idea.

---

<div class="post-metadata">

**Author:** ![k3KAW8Pnf7mkmdSMPHz2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/k3kaw8pnf7mkmdsmphz2/32/1116_2.png) [@k3KAW8Pnf7mkmdSMPHz2](https://discourse.jabref.org/u/k3KAW8Pnf7mkmdSMPHz2)\
**Post date:** [July 31, 2021, 2:15am UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/3 "2021-07-31T02:15:59Z")

</div>

Which version of JabRef do you use? In my opinion `[`journal:regex("\_","")]`` is the most likely to succeed, but I can’t really test anything before Monday 😕

---

<div class="post-metadata">

**Author:** ![ggieling](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@ggieling](https://discourse.jabref.org/u/ggieling)\
**Post date:** [August 2, 2021, 7:02am UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/4 "2021-08-02T07:02:23Z")

</div>

From about JabRef:  
JabRef 5.4–2021-07-24–1cdd807  
Windows 10 10.0 amd64  
Java 16.0.1  
JavaFX 16+8

I tried the regex, but it doesn’t solve the issue.

An additional observation:  
After applying the function: `Rename file to a given pattern`. This option is inactivated for this item and the filename can only be changed using `Rename file to a given name`. This makes sense as long as the settings in Options \> Preferences \> linked files \> Filaname format pattern are the same. But after changing this definition, the function should be available again.

---

<div class="post-metadata">

**Author:** ![k3KAW8Pnf7mkmdSMPHz2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/k3kaw8pnf7mkmdsmphz2/32/1116_2.png) [@k3KAW8Pnf7mkmdSMPHz2](https://discourse.jabref.org/u/k3KAW8Pnf7mkmdSMPHz2)\
**Post date:** [August 2, 2021, 8:11pm UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/5 "2021-08-02T20:11:52Z")

</div>

What @Siedlerchr says is correct. The `:regex` modifier respects `{protected}` terms. The correct way of dealing with this should be `[JOURNAL:unprotect_terms]`, but for some reason, `unprotect_terms` is currently not included in the available modifiers.

Until it is (re?)added I think `[JOURNAL:latex_to_unicode]` is your best bet, although the `latex_to_unicode` can have unexpected consequences.

> [@ggieling](#):
>
> After applying the function: `Rename file to a given pattern` . This option is inactivated for this item and the filename can only be changed using `Rename file to a given name` .

There does seem to be some bug with updating the file name pattern, I’ve had to restart JabRef before it worked properly. I think there was a GitHub issue or PR regarding preferences not always updating correctly. I’ll have to see if I can dig that one up.

---

<div class="post-metadata">

**Author:** ![k3KAW8Pnf7mkmdSMPHz2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/k3kaw8pnf7mkmdsmphz2/32/1116_2.png) [@k3KAW8Pnf7mkmdSMPHz2](https://discourse.jabref.org/u/k3KAW8Pnf7mkmdSMPHz2)\
**Post date:** [August 2, 2021, 8:58pm UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/6 "2021-08-02T20:58:52Z")

</div>

[Add `unprotect_terms` to the list of modifiers for bracketed patterns by k3KAW8Pnf7mkmdSMPHz27 · Pull Request #7960 · JabRef/jabref · GitHub](https://github.com/JabRef/jabref/pull/7960) for the re-adding.

---

<div class="post-metadata">

**Author:** ![ggieling](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@ggieling](https://discourse.jabref.org/u/ggieling)\
**Post date:** [August 3, 2021, 2:17pm UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/7 "2021-08-03T14:17:52Z")

</div>

> [@k3KAW8Pnf7mkmdSMPHz2](#):
>
> although the `latex_to_unicode` can have unexpected consequences.

What could be such consequences? Are they discussed somewhere (manual or this forum)?

---

<div class="post-metadata">

**Author:** ![k3KAW8Pnf7mkmdSMPHz2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/k3kaw8pnf7mkmdsmphz2/32/1116_2.png) [@k3KAW8Pnf7mkmdSMPHz2](https://discourse.jabref.org/u/k3KAW8Pnf7mkmdSMPHz2)\
**Post date:** [August 3, 2021, 6:34pm UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/8 "2021-08-03T18:34:53Z")

</div>

I don’t think they are discussed anywhere, and in general, it should be fine, it is just good to be aware that there are some limitations such as,

1. You can write latex expressions that cannot be represented in Unicode, and since we are using a third-part library for latex → unicode ([GitHub - tomtung/latex2unicode: Convert LaTeX markup to Unicode (in Scala and Java)](https://github.com/tomtung/latex2unicode)) it is up to it how it deals with those situations
2. If the field contains incorrect latex the original text is used instead (even if part of the latex is correct)
3. It doesn’t use or respect any style or included latex libraries

I wouldn’t expect any issue with `journal`, `author`, or similar, but I’d be more careful about using the `abstract`. And if you have 45 000 files it is likely that at least one `title` contains a latex expression that causes unexpected output (e.g., the wrong “var epsilon” char or incorrect latex).

Fortunately, most file systems support Unicode letters these days.

---

<div class="post-metadata">

**Author:** ![k3KAW8Pnf7mkmdSMPHz2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/k3kaw8pnf7mkmdsmphz2/32/1116_2.png) [@k3KAW8Pnf7mkmdSMPHz2](https://discourse.jabref.org/u/k3KAW8Pnf7mkmdSMPHz2)\
**Post date:** [August 3, 2021, 6:38pm UTC](https://discourse.jabref.org/t/filename-format-pattern-novice-user/2872/9 "2021-08-03T18:38:37Z")

</div>

If it is only this particular thing you are having an issue with, `unprotect_terms` should work in the latest dev version found at [index - powered by h5ai v0.29.0 (https://larsjung.de/h5ai/)](https://builds.jabref.org/main/)

Just remember to backup your library before using a dev build!
