Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Login
  • Contact Us
English (UK)
US English (US)
GB English (UK)

You Bring the MFT Questions

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

Popular Topics: Public,

  • Home
  • Public
  • Vendor - Specific
  • GoAnywhere

Iterating though a folder path in GoAnywhere

Written by Richard Auger

Updated at April 23rd, 2024

  • Public
    Vendor - Specific
+ More

 

We tend to think as collections being vertical things that we can loop through - a list of names or files etc.  However, you could also consider a folder path as a collections too, and may want to act on every folder in the path.  This could be because you need to create the actual folders before performing a move operation (which would fail if the folder structure did not yet exist).

Luckily, it is quite straightforward to iterate through a folder path in this way by using a ‘Do-While’ loop.  The logic that you need is simply this:

Start by setting a variable, in this example I have called the variable ‘path’ and it contains the value ‘\abc\def\ghi\’.  I am relying on the leading and trailing slash for correctly parsing the path, so it may be necessary to add them if they are missing.

Before entering the loop I am creating a second variable called temppath which will have the same value as path - I don't want to change the path variable value.

The Do-While loop requires a condition - it is simply this:

${PositionOf(temppath, '\',2)<>-1}

This basically says to keep looping as long as the temppath variable contains the backslash character.

Now that the loop starts, we get the first folder in the path by using a substring

The substring starts AFTER the leading slash and ends immediately before the subsequent slash (using ‘positionof’ to locate the slash)

You can then work with the folder - creating it or whatever else you need to do (here it is just a print)

Finally, we update the temppath variable by again creating a substring, starting AFTER the leading slah, but running until the end of the existing string.

This is the resulting log:

directory traversing

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  1. Too many open files Error

     242 views of this article

  2. How to Set Up OAUTH2 in GoAnywhere

     766 views of this article

  3. Azure Blob Object UNC Access

     287 views of this article

Copyright © 2025 Pro2col Ltd

Terms of Sale

Privacy Policy

Support T's & C's


Knowledge Base Software powered by Helpjuice

Expand