I want to create subdirectories for attachments, similar to how previously did it with Zotfile. As far as I can tell, this is the file directory pattern
setting under Linked Files
– however, I tried pretty much everything and cannot figure out how to get it to work. I tried the citation key tags []
which work with the file name pattern, but that also did not work.
Following the information in this forum post, I also tried stuff like \year
which did not work either. There also doesn’t seem to be much documentation on this subject.
Can someone help me out? My goal would be to create subdirectories like
[auth1]/[authEtAl]/[year]/thefile.pdf
Hi,
Your pattern is correct and works fine for me. Have you defined a main file directory?
If you have already attached files and want them to move, you can use the Quality → Cleanup entries → Check Moe files to default file directory
1 Like
Well, in that case it might be some sort of bug on my side?
Because I have defined a main directory and have pretty much the same settings as you, but every time I drop a file on the reference entry, it the file ends up in the main file directory without any subfolders.
It works for the cases I’ve tested as well
- Would you mind showing the full
Filename format pattern
?
- Does your main file directory exist?
- What (if anything) happens if you manually move the file to the directory from within the JabRef entry editor?
@armenaton Could you elaborate which JabRef version you are using and on which system? (e.g. linux/snap). We both tested in the latest 5.3 release
This is the file renaming pattern. I tried the default pattern as well and it didnt make a difference though.
[authEtAl]_[year]_[title]_[firstpage]-[lastpage]
The directory pattern is:
[auth1]/[authEtAl]/[year]
The main file directory exists. All the – correctly renamed – files end up there. Only the creation of subdirectories is not happening.
I am also on the latest version:
JabRef 5.3–2021-07-05–50c96a2
Mac OS X 11.4 x86_64
Java 16.0.1
JavaFX 16+8
Moving to the file directory is greyed out for me
(sorry for the second post, I am not allowed to post multiple images yet as new user.)
This is weird. The greyed-out makes sense thinking about it. It should be greyed out if the file already has the directory and file name that JabRef believes it should, and therefore believes there is nothing to do.
What if you only put a directory name in the directory pattern?
instead of
[auth1]/[authEtAl]/[year]
just put
Debugging
I just tried it, the fiel still gets placed into the main file directory. No “debugging” subdirectory is created.
I also tried reinstalling Jabref and creating a new library for testing. Issue still persists.
Okay, I experimented a bit and it seems that this is a bug related to the drag & drop function.
With this workaround, everything works as it is supposed to:
rightclick entry ➞ attach file ➞ select pdf ➞ double-click entry to open ➞ Tab “General” ➞ scroll down to “File” ➞ rightclick the attachment ➞ select the “Move file to file directory and rename” (which is not greyed out now)
Now the subdirectories are created.
Obviously, this is an annoyingly tedious process compared to simply using drag & drop. Especially when you have to do it regularly. But it seems to further indicate that some bug is at work here.
well this is weird. After experimenting a bit more, I got this error message.
in the details is the following error message.
java.lang.UnsupportedOperationException: Flush is forbidden from target!
at org.jabref.merged.module@5.3.60000/com.sun.glass.ui.View$2.flush(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.QuantumClipboard.flush(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.QuantumToolkit.startDrag(Unknown Source)
at org.jabref.merged.module@5.3.60000/javafx.scene.Scene$DnDGesture.dragDetectedProcessed(Unknown Source)
at org.jabref.merged.module@5.3.60000/javafx.scene.Scene$DnDGesture.process(Unknown Source)
at org.jabref.merged.module@5.3.60000/javafx.scene.Scene$MouseHandler.process(Unknown Source)
at org.jabref.merged.module@5.3.60000/javafx.scene.Scene.processMouseEvent(Unknown Source)
at org.jabref.merged.module@5.3.60000/javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.glass.ui.View.notifyMouse(Unknown Source)
at org.jabref.merged.module@5.3.60000/com.sun.glass.ui.mac.MacView.notifyMouse(Unknown Source)
Not sure enough about JavaFX to tell you what is going on there
That is the full error message?
I think your original issue might come from a mistake in how the directory name is checked. If the file is in the root of your file directory it is always considered to be in the right place (which is why the action to move it is grayed out).
I am less sure why your workaround works though
I added #7908 on GitHub.
Just one last thing, the cleanup action does not work either? With the Move files to default file directory
, (same as christoph)
1 Like
Regarding drag and drop, JabRef uses modifier keys, but there is a bug in java/javafx https://bugs.openjdk.java.net/browse/JDK-8264172
Thanks for creating the issue!
Also, the cleanup action works perfectly. Pressing a hotkey once is much, much more convenient than the tedious workaround I found, so it’s the best solution until the drag&drop bug is fixed, I guess.
Another question as I have experimented a bit with renaming patterns: is it somehow possible to make certain characters only appear when a expression is present? In case of my renaming pattern
[authEtAl]_[year]_[title]_[firstpage]-[lastpage]
there are instances where there is aren’t first and last pages (e.g., a monography). In that case, Jabref still appends the _-
which is unnecessary when there without the page information. It results in something like this:
PassothEtAl_2012_Agency without Actors_ New Approaches to Collective Action_-.pdf
Is it possible to prevent the _-
from occurring when there are no page numbers?
Not really, no. You can work around it like this, which should work in most circumstances. I had a lot of issues actually saving the pattern. Not sure what went on there
[authEtAl]_[year]_[title][firstpage:regex(".+", "_$0")][lastpage:regex(".+", "-$0")]
1 Like
works perfectly for me, thanks!
1 Like