From 92b85926528939c1d7d9d2eb9022888db30165b4 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 13 Apr 2016 18:41:04 +0000 Subject: [PATCH] // try to merge overlapping path sections --- .../net/filebot/ui/rename/ExpressionFormatter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/ui/rename/ExpressionFormatter.java b/source/net/filebot/ui/rename/ExpressionFormatter.java index 6535f5d9..a1a07b07 100644 --- a/source/net/filebot/ui/rename/ExpressionFormatter.java +++ b/source/net/filebot/ui/rename/ExpressionFormatter.java @@ -76,13 +76,13 @@ class ExpressionFormatter implements MatchFormatter { // try to resolve against structure root folder by default try { File structureRoot = getStructureRoot(source); - File destinationRoot = listPath(parent).get(0); - while (structureRoot != null) { - // try to merge overlapping path sections - if (!structureRoot.getName().equals(destinationRoot.getName())) { - return new File(structureRoot, destination).getPath(); + if (structureRoot != null) { + for (File f : listPath(parent)) { + if (isStructureRoot(f)) { + structureRoot = structureRoot.getParentFile(); + } } - structureRoot = structureRoot.getParentFile(); + return new File(structureRoot, destination).getPath(); } } catch (Exception e) { debug.log(Level.SEVERE, "Failed to resolve structure root: " + source, e);