Script with foreach is deselecting my selection
Posted: 06 Sep 2018 20:18
Hello, I'm wondering if someone may have an idea about an issue I'm having. I have a script that does a copyto of files in selected directories to another location. But within this script I have it call another script that deletes all the sub-directories of any selected directories first. Issue is, after it runs this script that deletes any sub-directories, it deselects my originally selected directories. I need the original directories that were selected to remain selected for the copyto portion of my script.
The called script that removes the sub-directories and deselects my original directories is as follows:
Thank you for the help.
The called script that removes the sub-directories and deselects my original directories is as follows:
Code: Select all
msg "Remove all Sub-Directories and their files of selected Folder(s)?", 1;
foreach($folder, "<get SelectedItemsNames |>") {
if (exists("<curpath>\$folder") != 2) { continue; }
$m = report("{Modified yyyy-mm-dd hh:nn:ss}", "<curpath>\$folder");
$c = report("{Created yyyy-mm-dd hh:nn:ss}", "<curpath>\$folder");
$a = report("{Accessed yyyy-mm-dd hh:nn:ss}", "<curpath>\$folder");
setting "BackgroundFileOps", 0;
$foldersRoot = listfolder("<curpath>\$folder", , 2);
if (listfolder("<curpath>\$folder", , 2) != "") {
delete 1, 0, $foldersRoot;
timestamp m, $m, "<curpath>\$folder";
timestamp c, $c, "<curpath>\$folder";
timestamp a, $a, "<curpath>\$folder";
}
}
status Complete!;