Created
May 4, 2016 14:23
-
-
Save tetkuz/28b4aa92c6d567d014d07166dcc74c7e to your computer and use it in GitHub Desktop.
Rename files which exported from x-app
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.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