Created
August 1, 2020 19:00
-
-
Save baobao/8a12c1156263ff25232c0b3c4f3dd540 to your computer and use it in GitHub Desktop.
Rename Sample `.txt` to `.cs`
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
#!/usr/bin/env dotnet-script | |
/** | |
* Rename Sample .txt to .cs | |
*/ | |
if (Args == null || Args.Count < 0) | |
{ | |
Console.WriteLine("Require arguments"); | |
return; | |
} | |
var dirPath = Args[0]; | |
var files = Directory.GetFiles(".", "*.txt"); | |
foreach(var filePath in files) | |
{ | |
var dirPath = Path.GetDirectoryName(filePath); | |
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath); | |
var newPath = $"{dirPath}/{fileNameWithoutExtension}.cs"; | |
File.Move(filePath, newPath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment