diff --git a/Subforms/PKM Editors/BatchEditor.cs b/Subforms/PKM Editors/BatchEditor.cs index aa31213e7..c3a4ed7ea 100644 --- a/Subforms/PKM Editors/BatchEditor.cs +++ b/Subforms/PKM Editors/BatchEditor.cs @@ -65,6 +65,18 @@ private void runBackgroundWorker() if (Instructions.Any(z => string.IsNullOrWhiteSpace(z.PropertyValue))) { Util.Error("Empty Property Value detected."); return; } + string destPath = ""; + if (RB_Path.Checked) + { + Util.Alert("Please select the folder where the files will be saved to.", "This can be the same folder as the source of PKM files."); + var fbd = new FolderBrowserDialog(); + var dr = fbd.ShowDialog(); + if (dr != DialogResult.OK) + return; + + destPath = fbd.SelectedPath; + } + FLP_RB.Enabled = RTB_Instructions.Enabled = B_Go.Enabled = false; b = new BackgroundWorker {WorkerReportsProgress = true}; @@ -80,7 +92,7 @@ private void runBackgroundWorker() { var files = Directory.GetFiles(TB_Folder.Text, "*", SearchOption.AllDirectories); setupProgressBar(files.Length); - processFolder(files, Filters, Instructions); + processFolder(files, Filters, Instructions, destPath); } }; b.ProgressChanged += (sender, e) => @@ -161,7 +173,7 @@ private void processSAV(PKM[] data, List Filters, List Filters, List Instructions) + private void processFolder(string[] files, List Filters, List Instructions, string destPath) { len = err = ctr = 0; for (int i = 0; i < files.Length; i++) @@ -183,7 +195,7 @@ private void processFolder(string[] files, List Filters, List if (r == ModifyResult.Modified) { ctr++; - File.WriteAllBytes(file, pkm.DecryptedBoxData); + File.WriteAllBytes(Path.Combine(destPath, Path.GetFileName(file)), pkm.DecryptedBoxData); } b.ReportProgress(i);