Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

How to iterate through directories and sub-directories?

Trivius

New Coder
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

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:
It's a scripting language for a Windows program written in Pascal, but is not a mainstream language itself. So, not sure where to post, but really just need assistance in general. I'll convert the commands/syntax as applicable.
 
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

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
Hi there,
May I ask why you need this functionality?
 
Hi there,
May I ask why you need this functionality?
Hi, I need it to call on for file searches, to do so I need to include the paths to each individual file. I will put this into a large array, organized from top down, which will allow me to then call on another function that arrays all files within a specified path. This will allow me to display or load whichever file being called on, e.g., via wildcard matches, etc., and the files will be visually organized by order of directories.
 
Hi, I need it to call on for file searches, to do so I need to include the paths to each individual file. I will put this into a large array, organized from top down, which will allow me to then call on another function that arrays all files within a specified path. This will allow me to display or load whichever file being called on, e.g., via wildcard matches, etc., and the files will be visually organized by order of directories.
Maybe my question wasn't clear...what are you trying to do with this functionality? I understand what you are asking help on, but what specifically are you trying to accomplish with what you call a "proxy program"?
 
Maybe my question wasn't clear...what are you trying to do with this functionality? I understand what you are asking help on, but what specifically are you trying to accomplish with what you call a "proxy program"?

Oh, sorry, okay, I think I understand your question now.

It's going to grant my family access to the mothership that will take us to planet Nibiru, where I will then be scheduled to meet secretly with L. Ron Hubbard and Joseph Smith and receive my next set of mission orders for aiding in global-homo-galactic domination with our Earth allied demonic reptilian sect, ironically named the "Lizard People."

Hope that answers any and all further questions that you may or may not have. Thank you for your time and consideration. It helped me so amazingly!
 
Oh, sorry, okay, I think I understand your question now.

It's going to grant my family access to the mothership that will take us to planet Nibiru, where I will then be scheduled to meet secretly with L. Ron Hubbard and Joseph Smith and receive my next set of mission orders for aiding in global-homo-galactic domination with our Earth allied demonic reptilian sect, ironically named the "Lizard People."

Hope that answers any and all further questions that you may or may not have. Thank you for your time and consideration. It helped me so amazingly!
Sarcasm will get you nowhere bud
🤣😂🤣😂🤣
 
Why are you using an obscure scripting language written in Pascal instead of an established language that people could actually help you with ? You are just making life difficult for yourself here.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom