I am needing to write a script function to iterate top down following throughout all sub-directories as it moves down the main directories from a provided path. I need this as a core to a script I've been working on to search through all files within. I am totally stuck on how to accomplish this, as I'm only achieving erratic returns and/or array errors. I've been unable to comprehend how to keep my arrays ordered or aligned as it follows paths to the end, then steps backwards searching for more directories to move down and/or branch outward until all directories have been added into the array.
This is a scripting language for a proxy program that includes a 'getDirList' function to return an array of directories for an included path (I can then array all files from within that list of directories.) This is the code I have now, but it does not work properly, I am hoping someone could provide an example of accomplishing this properly using a while/if loop? I've been working at this for several weeks now only to fail repeatedly at it and fear I've lost my objectivity. It seems that this should be easy to accomplish and straight forward, so, I don't get what it is that I'm not seeing. TIA
This is a scripting language for a proxy program that includes a 'getDirList' function to return an array of directories for an included path (I can then array all files from within that list of directories.) This is the code I have now, but it does not work properly, I am hoping someone could provide an example of accomplishing this properly using a while/if loop? I've been working at this for several weeks now only to fail repeatedly at it and fear I've lost my objectivity. It seems that this should be easy to accomplish and straight forward, so, I don't get what it is that I'm not seeing. TIA
Code:
$SCRIPTSPATH := "C:\Scripts\"
$folder_path := $SCRIPTSPATH
$directories[1] := $SCRIPTSPATH
$directories[1][1] := 1
$i := 1
$c := 1
(begin while loop...)
goSub :GETDIRLIST
if ($folders > 0) AND ($directories[$c][1] <= $folders)
$i++
$directories[$i] := $folder_path & $folders[$directories[$c][1]] & "\"
$folder_path := $directories[$i]
$directories[$c][1]++
else
if ($folders = 0) AND ($directories[$c][1] > $folders)
$c++
elseif ($directories[$c][1] > $folders)
$c--
end
$folder_path := $directories[$c]
end
(end...)
:GETDIRLIST
getDirList $folders $folder_path
return
Last edited: