private static TextReplacement GetTextReplacement() { TextReplacement result = null; string oldText = Prompt("Enter the old text to be replaced (type done to finish)"); if (!oldText.Equals("done")) { string newText = Prompt("Enter the text to replace it with (type done to finish)"); if (!newText.Equals("quit") && !newText.Equals("done")) { result = new TextReplacement(oldText, newText); } } return(result); }
public static void ConfigureCopyAndRename() { List <string> textReplacementFileExtensions = new List <string>(); List <string> copyExtensions = new List <string>(); string answer = ""; while (!answer.Equals("done")) { if (!string.IsNullOrEmpty(answer)) { textReplacementFileExtensions.Add(answer); } answer = GetTextReplacementExtension(); } answer = GetCopyFileExtension(); bool copyAll = false; if (answer.ToLowerInvariant().Equals("all")) { copyAll = true; } else { while (!answer.Equals("done")) { if (!string.IsNullOrEmpty(answer)) { copyExtensions.Add(answer); } answer = GetCopyFileExtension(); } } List <TextReplacement> textReplacements = new List <TextReplacement>(); TextReplacement replacement = new TextReplacement("", ""); while (replacement != null) { if (!string.IsNullOrEmpty(replacement.OldText)) { textReplacements.Add(replacement); } replacement = GetTextReplacement(); } string sourceFolder = Prompt("Enter the source folder path"); string targetFolder = Prompt("Enter the target folder path"); RenCopyConfig config = new RenCopyConfig(); config.SourceFolder = sourceFolder; config.TargetFolder = targetFolder; config.TextReplacementFileExtensions = textReplacementFileExtensions.ToArray(); config.CopyExtensions = copyExtensions.ToArray(); config.CopyAllFiles = copyAll; config.TextReplacements = textReplacements.ToArray(); config.ToJsonFile(_configFile); if (Confirm("Copy files now?")) { CopyAndRename(); } }