123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using UnityEngine;
- using UnityEditor;
- using System.IO;
- using System.Text.RegularExpressions;
- public class RenameSoundTool
- {
- [MenuItem("Tools/Rename Sounds to lowercase", false)]
- static void NotGetFiltered()
- {
- string targetPath = Application.dataPath + "/Res/Sounds";
- var count = 0;
- RenameDir(targetPath, ref count);
- Debug.Log($"Rename sound files count :{count}");
-
- AssetDatabase.Refresh();
- }
- static void RenameDir(string dir, ref int count)
- {
- DirectoryInfo di = new DirectoryInfo(dir);
- var files = di.GetFiles();
- // 遍历这个目录
- foreach (var f in files)
- {
- //绕过mate文件
- if (f.Extension != ".meta")
- {
- var m = Regex.Match(f.Name, ".*[A-Z]+.*");
- if (m.Success)
- {
- File.Delete(Path.Combine(f.Directory.FullName, f.Name + ".meta"));
- f.MoveTo(Path.Combine(f.Directory.FullName, f.Name.ToLower()));
- ++count;
- }
- }
- }
- foreach(var dd in di.GetDirectories())
- {
- RenameDir(dd.FullName, ref count);
- }
- }
- }
|