Created
February 13, 2019 17:32
-
-
Save Logxn/2847cf97b738d781807fdfd643babc3d to your computer and use it in GitHub Desktop.
Xenos Datei Sortiermaschine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using System.IO; | |
using System.Text.RegularExpressions; | |
namespace Xenos_Datei_Sortier_Maschine | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.Title = "Xenos Datei Sortier Maschine - by Logxn"; | |
Console.WriteLine($"Verschiebe Files..."); | |
var executingPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | |
foreach(var fileLocation in Directory.GetFiles(executingPath)) | |
{ | |
var fileName = Path.GetFileName(fileLocation); | |
var match = Regex.Match(fileName, @"^.*?(?=_)"); | |
if(match.Success) | |
{ | |
var matchedName = match.Value; | |
var dirToMove = $@"{executingPath}\{matchedName}"; | |
if(Directory.Exists(dirToMove)) | |
{ | |
File.Move(fileLocation, $@"{dirToMove}\{fileName}"); | |
} | |
continue; | |
} | |
continue; | |
} | |
Console.WriteLine($"Alle Files sollten verschoben worden sein, LG Logxn."); | |
while (true) { } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment