diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index d29adb68..6fd3a39f 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -561,7 +561,7 @@ public class CmdlineOperations implements CmdlineInterface { Map renameMap = new LinkedHashMap(); for (Entry it : service.getMetaData(selection).entrySet()) { - MediaBindingBean bindingBean = new MediaBindingBean(it.getValue(), it.getKey(), null); + MediaBindingBean bindingBean = new MediaBindingBean(it.getValue(), it.getKey()); if (filter == null || filter.matches(bindingBean)) { String newName = (format != null) ? format.format(bindingBean) : validateFileName(it.getValue().toString()); diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index b0fab51d..50924771 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -64,6 +64,10 @@ public class MediaBindingBean { private MediaInfo mediaInfo; private Object metaInfo; + public MediaBindingBean(Object infoObject, File mediaFile) { + this(infoObject, mediaFile, singletonMap(mediaFile, infoObject)); + } + public MediaBindingBean(Object infoObject, File mediaFile, Map context) { this.infoObject = infoObject; this.mediaFile = mediaFile; @@ -756,7 +760,7 @@ public class MediaBindingBean { @Define("i") public Integer getModelIndex() { - return identityIndexOf(context.values(), getInfoObject()); + return 1 + identityIndexOf(context.values(), getInfoObject()); } @Define("di") diff --git a/source/net/filebot/ui/rename/BindingDialog.java b/source/net/filebot/ui/rename/BindingDialog.java index 8049b707..ba46c653 100644 --- a/source/net/filebot/ui/rename/BindingDialog.java +++ b/source/net/filebot/ui/rename/BindingDialog.java @@ -110,7 +110,7 @@ class BindingDialog extends JDialog { if (bindingModel.executor.isShutdown()) return; - bindingModel.setModel(getSampleExpressions(), new MediaBindingBean(getInfoObject(), getMediaFile(), null)); + bindingModel.setModel(getSampleExpressions(), new MediaBindingBean(getInfoObject(), getMediaFile())); } }; diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index f062aa12..4c453570 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -24,7 +24,6 @@ import java.io.File; import java.io.IOException; import java.net.URI; import java.text.Format; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -447,7 +446,7 @@ public class FormatDialog extends JDialog { media = new File(path); } - return new MediaBindingBean(info, media, Collections.singletonMap(media, info)); + return new MediaBindingBean(info, media); } private ExecutorService createExecutor() { @@ -642,7 +641,7 @@ public class FormatDialog extends JDialog { File file = dialog.getMediaFile(); // change sample - sample = new MediaBindingBean(info, file, Collections.singletonMap(file, info)); + sample = new MediaBindingBean(info, file); // remember sample try {