JabRef version on
JabRef 5.3--2021-07-14--477118c
Mac OS X 10.15.7 x86_64
Java 16.0.1
JavaFX 16+8
Steps to reproduce the behavior:
- In
Options -> Preferences -> Linked files, make sure that
1.1. There is an absolute path for Main file directory
1.2. Search and store files relative to library file location is OFF
1.3. There is a non-empty File directory pattern (e.g., Debugging)
- Have an entry with a linked file and open the entry-editor
2.1. If the linked file is in the Main file directory, the Move file to file directory will always be disabled (instead of giving the option to move the file to the correct directory)
2.2. If the linked file is in the correct directory, the Move file to file directory is always enabled (even if it doesn't do anything, because it tries to move the file to the directory it is already in)

The
|
public boolean isGeneratedPathSameAsOriginal() { |
|
Optional<Path> newDir = databaseContext.getFirstExistingFileDir(filePreferences); |
|
|
|
Optional<Path> currentDir = linkedFile.findIn(databaseContext, filePreferences).map(Path::getParent); |
|
|
|
BiPredicate<Path, Path> equality = (fileA, fileB) -> { |
|
try { |
|
return Files.isSameFile(fileA, fileB); |
|
} catch (IOException e) { |
|
return false; |
|
} |
|
}; |
|
return OptionalUtil.equals(newDir, currentDir, equality); |
|
} |
should probably add a suggested directory name to newDir, similar to
|
public String getSuggestedFileName() { |
|
String oldFileName = fileEntry.getLink(); |
|
|
|
String extension = FileHelper.getFileExtension(oldFileName).orElse(fileEntry.getFileType()); |
|
return getSuggestedFileName(extension); |
|
} |
but using
|
public static String createDirNameFromPattern(BibDatabase database, BibEntry entry, String directoryNamePattern) { |
The origin is this bug report is https://discourse.jabref.org/t/how-to-use-file-directory-pattern/2802/
JabRef version on
Steps to reproduce the behavior:
Options->Preferences->Linked files, make sure that1.1. There is an absolute path for
Main file directory1.2.
Search and store files relative to library file locationis OFF1.3. There is a non-empty
File directory pattern(e.g.,Debugging)2.1. If the linked file is in the
Main file directory, theMove file to file directorywill always be disabled (instead of giving the option to move the file to the correct directory)2.2. If the linked file is in the correct directory, the
Move file to file directoryis always enabled (even if it doesn't do anything, because it tries to move the file to the directory it is already in)The
jabref/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java
Lines 327 to 340 in 477118c
should probably add a suggested directory name to
newDir, similar tojabref/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java
Lines 124 to 129 in 477118c
but using
jabref/src/main/java/org/jabref/logic/util/io/FileUtil.java
Line 290 in 477118c
The origin is this bug report is https://discourse.jabref.org/t/how-to-use-file-directory-pattern/2802/