Jabref: Direct file renaming

Created on 3 Apr 2019  ·  17Comments  ·  Source: JabRef/jabref

Hello everybody,

Is it possible to add (or to point it out, if i missed it) the function of arbitrary renaming of attached files directly from JabRef? So that it won’t be needed to edit both file name and corresponding entry.

I'm aware of batch rename capabilities of JabRef, but it would be nice just to make a right click on entry and have “rename attached file” option, which would only require to enter new name once.

Thank you

entry-editor external files good first issue waiting-for-customer-feedback enhancement

Most helpful comment

I could partly reproduce this. Windwos 10 here

  1. Set main file directory in options Preferences.
  2. Add PDF file in that directory to bib entry Zhou2002 - Named Entity Recognition Using an HMM Based Chunk Tagger.pdf
  3. Rename file
  4. The file is renamed in the GUI but not on disk
  5. Fhe old file still exists on disk
    I get the following error.
14:13:22.291 [JavaFX Application Thread] ERROR org.jabref.logic.util.io.FileUtil - Renaming Files failed - java.nio.file.NoSuchFileException: Zhou2002 - Named Entity Recognition Using an HMM Based Chunk Tagger.pdf
    at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsFileCopy.move(Unknown Source) 

All 17 comments

Hi,
@kaiquekk and I would like to work on this issue.

Thanks to @kaiquekk and coworkers, this is now implemented in the latest development version. Could you please check the build from http://builds.jabref.org/master/. Thanks! Please remember to make a backup of your library before trying-out this version.

Tried this feature it on my Win10 x64 with the .jar variant of the snapshot - did not work. It only changes "file"-string, but doesn't rename the attached file in corresponding folder.

@kaiquekk can you please have a look at the problem described by @harpax78 . Thanks!

We tried the latest .jar development version snapshot on two different Win10 x64 and the rename worked. Can you tell us more information about the problem?

before
rename
after

The problem is still here for me. Maybe that's because I have relative file links in my DB or because I use Directory Opus instead of default Win File Explorer.

@harpax78 Could it be that the file is open in another application (e.g. in a PDF reader or your file explorer)? In this case, we cannot rename the file because the other application blocks it. Could you please test it with just having JabRef open and nothing else. Thanks.

Well, I killed processes of Firefox and Directory Opus. Couldn't find any background processes for any of my PDF viewers, disabled Kaspersky. Still unable to rename file itself.

Is there anything logged in the event log (check at Help -> View event log)?

Opening: 'D:\LIBRARY 2019-04-27#LIBRARYNewLib.bib'
Files opened: 1
Opening: D:\LIBRARY 2019-04-27#LIBRARYNewLib.bib
Opened library 'D:\LIBRARY 2019-04-27#LIBRARYNewLib.bib' with 3821 entries.
Can only load style files: Preview
Preview style changed to: Preview
Renaming Files failed
java.nio.file.NoSuchFileException: Library I.Data\a099.PDF
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsFileCopy.move(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.move(Unknown Source)
at java.nio.file.Files.move(Unknown Source)
at org.jabref.logic.util.io.FileUtil.renameFileWithException(FileUtil.java:211)
at org.jabref.logic.util.io.FileUtil.renameFile(FileUtil.java:195)
at org.jabref.logic.util.io.FileUtil.renameFile(FileUtil.java:180)
at org.jabref.gui.fieldeditors.LinkedFileViewModel.lambda$renameFile$889(LinkedFileViewModel.java:365)
at java.util.Optional.ifPresent(Unknown Source)
at org.jabref.gui.fieldeditors.LinkedFileViewModel.renameFile(LinkedFileViewModel.java:362)
at org.jabref.gui.fieldeditors.LinkedFilesEditor.lambda$createContextMenuForFile$934(LinkedFilesEditor.java:226)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$343(ContextMenuContent.java:1358)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$358(GlassViewEventHandler.java:432)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
at java.lang.Thread.run(Unknown Source)

Ah... that might be helpful ;-)
Can you please also provide us the information what was the full path to the file, what was the original file name and to which name you wanted to rename?

... but your guess _"Maybe that's because I have relative file links in my DB"_ might be indeed an aspect here...

I could partly reproduce this. Windwos 10 here

  1. Set main file directory in options Preferences.
  2. Add PDF file in that directory to bib entry Zhou2002 - Named Entity Recognition Using an HMM Based Chunk Tagger.pdf
  3. Rename file
  4. The file is renamed in the GUI but not on disk
  5. Fhe old file still exists on disk
    I get the following error.
14:13:22.291 [JavaFX Application Thread] ERROR org.jabref.logic.util.io.FileUtil - Renaming Files failed - java.nio.file.NoSuchFileException: Zhou2002 - Named Entity Recognition Using an HMM Based Chunk Tagger.pdf
    at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsFileCopy.move(Unknown Source) 

Ah... that might be helpful ;-)
Can you please also provide us the information what was the full path to the file, what was the original file name and to which name you wanted to rename?

... but your guess _"Maybe that's because I have relative file links in my DB"_ might be indeed an aspect here...

The path is following: D:\LIBRARY 2019-04-27#LIBRARY\Library I.Data
There is a "\" before the "#" - I don't know why it's not shown in the final version of the post.

Original name: a099.pdf
Target name: test-rename.pdf

I could partly reproduce this. Windwos 10 here

1. Set main file directory in options Preferences.

2. Add PDF file in that directory to bib entry  `Zhou2002 - Named Entity Recognition Using an HMM Based Chunk Tagger.pdf`

3. Rename file

4. The file is renamed in the GUI but not on disk

5. Fhe old file still exists on disk
   I get the following error.
14:13:22.291 [JavaFX Application Thread] ERROR org.jabref.logic.util.io.FileUtil - Renaming Files failed - java.nio.file.NoSuchFileException: Zhou2002 - Named Entity Recognition Using an HMM Based Chunk Tagger.pdf
  at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
  at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
  at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
  at sun.nio.fs.WindowsFileCopy.move(Unknown Source) 

Sounds pretty much the same.

Just for reference my path was C:\Users\\Documents\_JABREFTEMP

Thanks to @matthiasgeiger the remaining problems should be fixed now in the latest master.

Everything works. Thank you guys!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

diabl0w picture diabl0w  ·  3Comments

lenhard picture lenhard  ·  4Comments

c3h899 picture c3h899  ·  3Comments

a-torgovitsky picture a-torgovitsky  ·  3Comments

Siedlerchr picture Siedlerchr  ·  3Comments