[Homebrew]大量照片重新命名程式

摘要:[Homebrew]大量照片重新命名程式

同學有個需求,他想要將掃描的書籍重新命名,因為他掃描時都先掃描單數頁或偶數頁,所以需要將原本連號的檔案改成單數或偶數,再來就是需要預留補零,方便在檔案排序時使用...所以就花了一點時間寫一個...

比較值得提出來的大概就是以下這段程式碼,有需要的人請自行取用..

 

         int count=0;
            int Start = Convert.ToInt32(numericUpDownStart.Value);
            int Interval=Convert.ToInt32(numericUpDownInterval.Value);
            string FormatStr = string.Empty;
            FormatStr = FormatStr.PadLeft(Convert.ToInt32(numericUpDownDigit.Value), '0');
            foreach (ListViewItem lvItem in listItems.Items)
            {
                FileInfo fi = (FileInfo)lvItem.Tag;
                FileInfo targetFile = new FileInfo(fi.DirectoryName +"\\"+ txtTitle.Text.Trim() + Start.ToString(FormatStr) + fi.Extension);
                if (fi.Exists && !targetFile.Exists)
                {
                    fi.MoveTo(targetFile.FullName);
                    Start += Interval;
                    count++;
                }

                Application.DoEvents();
                progressBar1.Value++;
                progressBar1.Show();
            }
執行檔:RenameTools.rar