C# rename files

static void RenameFiles()
        {
            string sourceDir = @"D:\ll";
            string[] allFiles = Directory.GetFiles(sourceDir, "*.mp3", SearchOption.AllDirectories);

            if(allFiles!=null && allFiles.Any())
            {
                for(int i = 0; i < allFiles.Count(); i++)
                {
                    string newName =Path.Combine(sourceDir, i + ".mp3");
                    File.Move(allFiles[i], newName);                      
                }
            }            
        }

 

posted @ 2019-11-21 13:43  FredGrit  阅读(207)  评论(0编辑  收藏  举报