File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ public void Sort()
25
25
26
26
Regex regexFilename = new Regex ( config . FileRegex ) ;
27
27
Regex regexFolder = new Regex ( config . FolderRegex ) ;
28
+ Regex regexWhitespace = new Regex ( "[ ]{2,}" ) ;
28
29
29
30
foreach ( var file in Directory . GetFiles ( config . RootFolder , config . FileFilter ) )
30
31
{
@@ -35,8 +36,11 @@ public void Sort()
35
36
filename = filename . Replace ( match . Value , string . Empty ) . Trim ( ) ;
36
37
}
37
38
39
+ var folderNameWhitespaces = regexFolder . Replace ( filename , string . Empty ) ;
40
+ var folderNameFinal = regexWhitespace . Replace ( folderNameWhitespaces , " " ) ;
41
+
38
42
var ext = $ "{ filename } { Path . GetExtension ( file ) } ";
39
- var path = Path . Combine ( config . RootFolder , regexFolder . Matches ( filename ) [ 0 ] . Value . Trim ( ) ) ;
43
+ var path = Path . Combine ( config . RootFolder , folderNameFinal ) ;
40
44
Directory . CreateDirectory ( path ) ;
41
45
File . Move ( file , Path . Combine ( path , ext ) ) ;
42
46
}
Original file line number Diff line number Diff line change 1
1
{
2
- "RootFolder" : " E :\\ Anime \\ watching " ,
2
+ "RootFolder" : " D :\\ " ,
3
3
"FileRegex" : " \\ [.*?\\ ]" ,
4
- "FolderRegex" : " [A-Za-z0-9].*[^-] " ,
4
+ "FolderRegex" : " [^a-zA-Z ] " ,
5
5
"FileFilter" : " *.mkv"
6
6
}
You can’t perform that action at this time.
0 commit comments