* clean up path separators in episode names/titles
This commit is contained in:
parent
ee76deccd0
commit
94d1e91b22
|
@ -5,6 +5,7 @@ package net.sourceforge.filebot.format;
|
|||
import static net.sourceforge.filebot.MediaTypes.*;
|
||||
import static net.sourceforge.filebot.format.Define.*;
|
||||
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
|
||||
import static net.sourceforge.tuned.FileUtilities.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -47,7 +48,8 @@ public class EpisodeBindingBean {
|
|||
|
||||
@Define("n")
|
||||
public String getSeriesName() {
|
||||
return episode.getSeriesName();
|
||||
// clean up series name just in case there are any path separators like / or \
|
||||
return removePathSeparators(episode.getSeriesName());
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +67,8 @@ public class EpisodeBindingBean {
|
|||
|
||||
@Define("t")
|
||||
public String getTitle() {
|
||||
return episode.getTitle();
|
||||
// clean up episode title just in case there are any path separators like / or \
|
||||
return removePathSeparators(episode.getTitle());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
package net.sourceforge.filebot.ui.panel.rename;
|
||||
|
||||
|
||||
import static net.sourceforge.tuned.FileUtilities.*;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
|
@ -50,7 +52,8 @@ public class RenameModel extends MatchModel<Object, File> {
|
|||
|
||||
@Override
|
||||
public String format(Match<?, ?> match) {
|
||||
return String.valueOf(match.getValue()).trim();
|
||||
// clean up path separators like / or \
|
||||
return removePathSeparators(String.valueOf(match.getValue()).trim());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ public final class FileUtilities {
|
|||
* Invalid file name characters: \, /, :, *, ?, ", <, >, |, \r and \n
|
||||
*/
|
||||
public static final Pattern ILLEGAL_CHARACTERS = Pattern.compile("[\\\\/:*?\"<>|\\r\\n]");
|
||||
public static final Pattern PATH_SEPARATORS = Pattern.compile("[\\\\/]");
|
||||
|
||||
|
||||
/**
|
||||
|
@ -239,6 +240,11 @@ public final class FileUtilities {
|
|||
}
|
||||
|
||||
|
||||
public static String removePathSeparators(CharSequence path) {
|
||||
return PATH_SEPARATORS.matcher(path).replaceAll("");
|
||||
}
|
||||
|
||||
|
||||
public static final long KILO = 1024;
|
||||
public static final long MEGA = KILO * 1024;
|
||||
public static final long GIGA = MEGA * 1024;
|
||||
|
|
Loading…
Reference in New Issue