Skip to content

Instantly share code, notes, and snippets.

@tetkuz
Created May 4, 2016 14:23
Show Gist options
  • Save tetkuz/28b4aa92c6d567d014d07166dcc74c7e to your computer and use it in GitHub Desktop.
Save tetkuz/28b4aa92c6d567d014d07166dcc74c7e to your computer and use it in GitHub Desktop.
Rename files which exported from x-app
using System;
using System.Text.RegularExpressions;
using System.IO;
namespace RemameCS
{
class Program
{
static void Main(string[] args)
{
string dir;
string full_name;
string dst_name;
Regex rgx = new Regex("\\d+\\-");
string tmp;
for (int i = 0; i < args.Length; i++)
{
full_name = args[i];
dir = Path.GetDirectoryName(full_name);
tmp = rgx.Replace(Path.GetFileName(args[i]), "");
dst_name = Path.Combine(dir, tmp);
Console.WriteLine("{0} => {1}", full_name, dst_name);
if (File.Exists(dst_name))
{
Console.WriteLine("Error... File already exists.");
}
else {
File.Move(full_name, dst_name);
}
}
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment