Last active
August 29, 2015 14:14
-
-
Save pisarukv/96a7dbd22a81e905a573 to your computer and use it in GitHub Desktop.
c#
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.IO; | |
namespace Rename | |
{ | |
class MainClass | |
{ | |
static DirectoryInfo d = new DirectoryInfo(Directory.GetCurrentDirectory()); | |
static FileInfo[] Files = d.GetFiles("*.png"); | |
public static void Main(string[] args) | |
{ | |
Console.WriteLine(Directory.GetCurrentDirectory()); | |
foreach (var a in Files) | |
{ | |
Console.WriteLine(a.Name); | |
if (a.Name.Contains("@")) | |
{ | |
var index = a.FullName.LastIndexOf('.'); | |
var path = a.FullName.Substring(0, index - 3).TrimEnd() + ".png"; | |
try | |
{ | |
File.Move(a.FullName, path); | |
} | |
catch | |
{ | |
File.Delete(path); | |
File.Move(a.FullName, path); | |
} | |
} | |
} | |
if(args.Length != 0) | |
{ | |
Files = d.GetFiles("*.png"); | |
foreach(var a in Files) | |
{ | |
File.Move(a.FullName, args[0]+a.FullName); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment