Code: Select all
$Path = "<curpath>";
goto "$Path ? /flat";
$List = folderreport("files", "r", "$Path", "r", ,"|");
...
goto "$Path";
What are your thoughts?
Code: Select all
$Path = "<curpath>";
goto "$Path ? /flat";
$List = folderreport("files", "r", "$Path", "r", ,"|");
...
goto "$Path";
Code: Select all
Parent <DIR>
Child <DIR>
...
Child <DIR>
...
Child <DIR>
...
Code: Select all
// Version 2.0 / 2012-02-14
// Copyright 2012 - Zardoz2293
//
// 1) User | Manage Commands... --> Label: archive
// 2) User | Manage Commands... --> Label: unarchive
"_body"
// Declare
$c_Folder = 2; // Assumed to be a Folder.
$c_Pipe = "|";
$c_Action = "{A} ";
$c_status_progress = "progress";
$c_status_alert = "alert";
$c_status_ready = "ready";
$c_color_red = "FF0000";
$c_count = "count";
$c_BranchView = "? /:flat";
$c_NotFound = (-1);
$c_attrModeSet = 1;
$c_attrModeRemove = 4;
global $g_attrMode;
status( "Activity...", , $c_status_progress );
if ($g_attrMode != 0) {
// Mode: Deprecate.
$g_attrMode = $c_attrModeSet; // Set
} else {
// Mode: Undeprecate.
$g_attrMode = $c_attrModeRemove; // Remove
}
$TypeFind = "<curpath>";
$CountFolder = 0;
goto "$TypeFind" . "$c_BranchView";
// Process Each File.
$List = folderreport("files", "r", "$TypeFind", "r", , $c_Pipe);
// Add selected Folder to the list for processing.
if (exists( $TypeFind ) != $c_Folder) {
$Folder = "$TypeFind";
} else {
// Currently selected a Folder in the TreeView or ListView.
$List = folderreport("dirs", "r", "$TypeFind", "r", , $c_Pipe);
if ($List != "") {
$List = $TypeFind . $c_Pipe . $List;
} else {
$List = $TypeFind;
}
// Process Each Folder.
$ErrorFolder = 0;
foreach ( $Folder, $List, $c_Pipe, "r" ) {
if (exists( $Folder ) != $c_Folder) {
status( "Internal failure. The Object '" . $Folder . "' is reporting it isn't a Folder.", $c_color_red, $c_status_alert );
goto "$TypeFind"; //Restore original starting folder.
end( "Error Encountered. Processing Stopped." );
} else {
// Folder: Prefix "{A}".
$FindExisting = gettoken( $Folder, -1, "\" );
if (substr( $FindExisting, , strlen( $c_Action ) ) != $c_Action ) {
// Apply Prefix "{A}".
$Folder = renameitem( $c_Action . "*", $Folder );
if ($Folder == "") {
$ErrorFolder++;
status( "Action: " . $CountFolder . " Folder" . (($CountFolder != 1) ? "s, " : ", ") . "Rename Errors=" . $ErrorFolder, , $c_status_progress );
}
} elseif ($g_attrMode == $c_attrModeRemove) {
// Undeprecate only if Attribute Mode is Remove.
$Folder = renameitem( substr( $FindExisting, strlen( $c_Action ) ), $Folder );
if ($Folder == "") {
$ErrorFolder++;
status( "Action: " . $CountFolder . " Folder" . (($CountFolder != 1) ? "s, " : ", ") . "Rename Errors=" . $ErrorFolder, , $c_status_progress );
}
}
attrstamp( "h", $g_attrMode, $Folder );
$CountFolder++;
status( "Action: " . $CountFolder . " Folder" . (($CountFolder != 1) ? "s, " : ", ") . "Rename Errors=" . $ErrorFolder, , $c_status_progress );
}
}
}
// Finished.
assert strpos( $Folder, $c_BranchView ) == $c_NotFound, "Branch View NOT removed: $Folder", 1;
goto "$Folder"; //Restore original starting folder.
if ($ErrorFolder > 0) {
$Status = $c_status_alert;
} else {
$Status = $c_status_ready;
}
status( "Action: " . $CountFolder . " Folder" . (($CountFolder != 1) ? "s, " : ", ") . "Rename Errors=" . $ErrorFolder, , $Status );
releaseglobals;
"Unarchive : unarchive"
// Declare
global $g_attrMode;
$g_attrMode = 0; // Unarchive.
sub "_body";
"Archive : archive"
// Declare
global $g_attrMode;
$g_attrMode = 1; // Archive.
sub "_body"
// END: Main
It is my understanding that folderreport, at least, before BV existed didn't order the folders and files in a very specific order that is needed. For me, the ordering of the folders and files is a technique I've used and needed in systems work for 20+ years. Therefore, why it wasn't/isn't in folderreport? It seems BV was given capability beyond what folderreport can/will do. I don't like how BV changes the screen, from my perspective, nothing the end-user could do during an executing script should be capable of messed it up by introducing an unwanted branch in the execution path. I don't do any keyboard or mouse activity during the script processing, so that's not a top concern, although it is another issue with using BV. Frankly, I'm using BV as I find string processing for folders and files take a lot of overhead, and is error prone. I really don't want to do any kind of string processing within script, rather call script commands to perform those services.Twisten wrote:I've faced a somewhat similar situation, and this question comes to mind, why use branch view at all ?
You're already using folderreport to get a list of files with absolute paths and doing it recursively, using goto can only lead to complications if you rely on the result an accidental click in the GUI can screw up you script.
It appears to be random effect of BV staying in BV mode at the end of scripting sometimes. You can perform the script on the same folder structure over and over again, and then, one time it stuck in BV mode. I'm not sure I'm willing to modify the script to perform all of the string processing myself. I can get more mileage by writing a .NET app that performs those services and some other things I need as well in about the same time to do the rewrite.Twisten wrote:I realize this doesn't address what unexpected behavior you noticed with branch view but I hope it'll help with your script, I haven't used branch view personally (especially in scripts) so I can't comment on that part.
1. Your statement above: That is my understanding of BV's behavior.admin wrote:Not sure if this applies but BV is applied to any selected folder again. IOW, when a folder is selected in a BV list, then Toggle Branch View does NOT toggle it off for the current list, but open the selected folder in BV.
Does this explain what you experience?
Code: Select all
"main"
goto "F:\XY.Test\? /:flat";
goto "F:\XY.Test";
1. What I was getting with the UDC when the keyboard combination was continuously pressed: XY would get semi-locked up and pressing the ESC key was needed to get it out of whatever funk it was in (this was an exclusive XY thing as it doesn't happen with anything else in my system).admin wrote:OK, I will prevent script reentry from UDC.
BTW, did you use tweak ScriptRecursionWarningOff = 1? Otherwise you should have seen a warning instead of the phenomena...
Code: Select all
ScriptRecursionWarningOff=0
Zardoz2293 wrote:1. What I was getting with the UDC when the keyboard combination was continuously pressed: XY would get semi-locked up and pressing the ESC key was needed to get it out of whatever funk it was in (this was an exclusive XY thing as it doesn't happen with anything else in my system).admin wrote:OK, I will prevent script reentry from UDC.
BTW, did you use tweak ScriptRecursionWarningOff = 1? Otherwise you should have seen a warning instead of the phenomena...
2. Never saw any warning dialog. Therefore it must have never entered recursively.
XYplorer.ini3. The BV now stays on at the end of processing more consistently.Code: Select all
ScriptRecursionWarningOff=0
4. My script is now broken with the other BV changes.
5. If it wasn't a recursion issue with UDC and BV staying on, then this and my two other scripting items I've reported are not addressed.
Don, interesting, I consistently get the same kind of issues. I'm not concerned as I've taken another path regarding BV and eliminated it from my scripts. Everything now works as expected. Better to spend time on other subjects until or if others experience the phenomena. When you added the reverse foreach that added a significant dimension (enhancement) to scripting from my perspective. Again, thanks!admin wrote:I cannot reproduce it here. But I could get some issues (but not yours) before I prevented reentry.