refactor: ♻️ 2.0 (#3)

This commit is contained in:
2023-12-14 15:03:07 +08:00
committed by GitHub
parent 8c0dbcf1f4
commit cf2988b389
73 changed files with 1157 additions and 371 deletions

27
scripts/rename.csx Normal file
View File

@ -0,0 +1,27 @@
#r "nuget: NSExt, 1.1.0"
using NSExt.Extensions;
Console.WriteLine("请输入原始名称NSExt");
var oldName = Console.ReadLine().NullOrEmpty("NSExt");
Console.WriteLine("请输入替换名称:");
var newName = Console.ReadLine();
foreach (var path in Directory.EnumerateDirectories("../", $"*{oldName}*",
SearchOption.AllDirectories))
{
Console.Write($"{path} --> ");
var newPath = path.Replace(oldName, newName);
Directory.Move(path, newPath);
Console.WriteLine(newPath);
}
Console.WriteLine();
foreach (var path in Directory.EnumerateFiles("../", $"*.*", SearchOption.AllDirectories))
{
File.WriteAllText(path, File.ReadAllText(path).Replace(oldName, newName));
var newPath = path.Replace(oldName, newName);
if (newPath == path) continue;
Console.Write($"{path} --> ");
Directory.Move(path, newPath);
Console.WriteLine(newPath);
}