Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename format pattern issue #3582

Closed
bdcaf opened this issue Dec 28, 2017 · 14 comments
Closed

Filename format pattern issue #3582

bdcaf opened this issue Dec 28, 2017 · 14 comments

Comments

@bdcaf
Copy link

bdcaf commented Dec 28, 2017

JabRef version 4.1 on Mac OS X 10.13_2

I was doing my first cleanup on 4.1 and noticed that the filename format pattern and file directory pattern would not produce the desired path.

I fiddled around a little and here's a small example:

  1. set file directory pattern to \format[HTMLChars]{\author} (basically an example from manual CustomExports.
  2. cleanup a file - the file will be moved to path then unhelpful format{author}

I noticed I can just use [author] - but that will leave latex in the string - so not a general solution.

@tobiasdiez
Copy link
Member

Yes, we removed support for the old format (that is also used in the preview) in favor of the same bracketed syntax as for BibTex keys.

So if I understand you correctly, you want to remove the latex, right? The pattern [author:latex_to_unicode] should accomplish this.

@tobiasdiez tobiasdiez added cleanup-ops status: waiting-for-feedback The submitter or other users need to provide more information about the issue labels Dec 28, 2017
@bdcaf
Copy link
Author

bdcaf commented Dec 29, 2017

I see. The pattern I was trying to replace was a bit more complicated. In addition I need to limit the title length (but shorttitle is too short to be useful) and remove special characters that clash with my file system (like */\:).
Could you hint me what modifiers I would need?

@tobiasdiez
Copy link
Member

I fear that is currently not possible. These are all possible modifiers (sorry for the format, but their meaning should be more or less clear):

public static final List<Formatter> CONVERTERS = Arrays.asList(
new HtmlToLatexFormatter(),
new HtmlToUnicodeFormatter(),
new LatexToUnicodeFormatter(),
new UnicodeToLatexFormatter()
);
public static final List<Formatter> CASE_CHANGERS = Arrays.asList(
new CapitalizeFormatter(),
new LowerCaseFormatter(),
new ProtectTermsFormatter(),
new SentenceCaseFormatter(),
new TitleCaseFormatter(),
new UpperCaseFormatter()
);
public static final List<Formatter> OTHERS = Arrays.asList(
new ClearFormatter(),
new LatexCleanupFormatter(),
new MinifyNameListFormatter(),
new NormalizeDateFormatter(),
new NormalizeMonthFormatter(),
new NormalizeNamesFormatter(),
new NormalizePagesFormatter(),
new OrdinalsToSuperscriptFormatter(),
new RegexFormatter(),
new RemoveBracesFormatter(),
new UnitsToLatexFormatter(),
new EscapeUnderscoresFormatter()
);

If you describe in more detail what you want to achieve, we may add the necessary modifiers.

@bdcaf
Copy link
Author

bdcaf commented Dec 29, 2017

I think RegexFormatter would do it for me. Essentially I had one regexp /[^0-9a-zA-Z-+]//g and another one /^(.{,60}.*$/\1/. So could you hint how to use the regexp formater - is it something like:
[author:latex_to_unicode:regex/[^0-9a-zA-Z-+]//g:regex/^(.{,60}.*$/\1/].
The post https://github.com/JabRef/help.jabref.org/issues/179 left me kinda confused how to correctly use it. Is there any way of testing before doing an actual cleanup?

The rationale was that I was synching between mac - win - linux and one or the other had problems - these gave reasonable filenames for me.

@Siedlerchr
Copy link
Member

Siedlerchr commented Dec 29, 2017

I wonder what the problematic filenames are, because we have a method to clean up filenames and to replace illegal chars with underscores. The method is always called after the filename pattern.

These are the illegal chars (their ascii codes) https://www.branah.com/ascii-converter

    private static final int[] ILLEGAL_CHARS = {
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
            30, 31, 34,
            42,
            58,
            60, 62, 63,
            124
    };

@tobiasdiez
Copy link
Member

After having a look at the code, I think the syntax is [author:regex("find regex", "replace regex")], e.g. [author:regex(" ", "-")] should replace all spaces by dashes.

@bdcaf
Copy link
Author

bdcaf commented Dec 29, 2017

@Siedlerchr moving between machines I run into different issues.

On windows I encounter an issue when filenames get too long (something active directory I think - for me it triggers once the full path is around 100 characters).

On mac I have a HFS+ issue - when creating a file the system automatically does some unicode normalisation - however when looking up the same file it does not perform this normalisation, so the file is not found under the expected name (Triggers when umlauts and accents are in the name). see e.g. https://eclecticlight.co/2017/04/06/apfs-is-currently-unusable-with-most-non-english-languages/

Also / and \ are problematic for me. E.g. while writing the initial report I also experimented escaping the backslash - \\format[HTMLChars]{\\author} - produced a path \format{\author} - however in jabref the path was shown as /format{/author} and it was not able to open the file - however it did suggest to autolink it.

So not an issue of JabRef - rather of the underlying filesystems I try to counteract.
Currently I try to drastically remove anything that may in some way affect either platform. Though if I could put in a request it would be great to have a transliteration function like described at unicode that would convert to the accepted ascii representation (e.g. ä -> ae ).

@lenhard lenhard removed the status: waiting-for-feedback The submitter or other users need to provide more information about the issue label Feb 21, 2018
@davydden
Copy link

I have similar issues, in 3.8 i used to have \bibtexkey\begin{title}_\format[RemoveBrackets,RemoveLatexCommands,Replace("\s,_")]{\title}\end{title}.

I can get similar effect from [bibtexkey]_[title:latex_to_unicode:regex(" ","_")], with the missing RemoveBrackets. Hopefully this is not crucial.

@Siedlerchr
Copy link
Member

Closing this issue due to inactivity 💤
Please reopen the issue with additional information if the problem persists.

@krunal-shah
Copy link

krunal-shah commented Sep 24, 2020

I am trying to rename the linked files to something like First1 Last1 First2 Last2 ... where First{i} and Last{i} are the first and last names of the ith author respectively.

Any help on how this can be achieved would be greatly appreciated.

Thank you.

@allabur
Copy link

allabur commented Jun 3, 2023

Hello, like @krunal-shah I am trying to customize filename format pattern [importFileNamePattern] but it is not possible to choose a different parent from default ([bibtexkey] or [bibtek] - [title]). I would like to customize names of files PDF. For example something like: [bibtexkey]_[camel] or [veryshorttitle]. Is there a way to do that? Thanks

@ThiloteE
Copy link
Member

ThiloteE commented Jun 3, 2023

hello @allabur, while I have not tried your concrete example, in theory a customized pattern should be possible, according to the docs: https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#filename-format-and-file-directory-pattern

@Siedlerchr
Copy link
Member

You can simply enter a new pattern. The combo box allows modification

@allabur
Copy link

allabur commented Jun 3, 2023

Thank you guys @Siedlerchr and @ThiloteE. Actually I was making a mistake, pressing Enter after modification and the changes were not saving at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants