Skip to content

Instantly share code, notes, and snippets.

@Logxn
Created February 13, 2019 17:32
Show Gist options
  • Save Logxn/2847cf97b738d781807fdfd643babc3d to your computer and use it in GitHub Desktop.
Save Logxn/2847cf97b738d781807fdfd643babc3d to your computer and use it in GitHub Desktop.
Xenos Datei Sortiermaschine
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