The mgiListFolder Tag

Tag Behavior

Use the mgiListFolder tag to list all files and folders located in a specified folder. The mgiListFolder tag does not include hidden files or aliases in the file list.


Tag Syntax

The mgiListFolder tag has no required parameters and four optional parameter. The tag form is:

<mgiListFolder folderLocation="File Path" delimiter="Character" 
filter="Extension" resultVariableName="Name">

Required Parameters:

  • None.

Optional Parameters:

  • folderLocation - The folderLocation is the relative path to the folder to list. If the folderLocation is not provided, the folder containing the mgiListFolder tag is listed by default.
  • delimiter - The delimiter is the character that separates each value returned file list. To use escape characters such as carriage returns, line feeds, and tabs as delimiters use the appropriate Escaped String format. The default delimiter is a comma.
  • filter - The extension of the files to list. Each filter must begin with a wildcard, the asterisk (*). For example, the filter "*.jpg" will list all files with the .jpg extension and the filter "*.html" will list all files with the HTML extension. Multiple filter parameters may be included in one mgiListFolder tag. If the filter parameter is not included, all files and folders will be listed.
  • resultVariableName - The resultVariableName is the name prepended to result variables that contain information about the files and folders that are listed. You may choose any name for the result variable prefix. To display result variables use the mgiGet tag. In the following list of available result variables, the resultVariableName value is "resultvar". Result variables are created and available anywhere on the page after the mgiListFolder tag.
    • resultvar_Length- A page variable with the total number of files and folders in the list.


Example Usage and Output

<mgiListFolder>

In this example, the files and folders on the same level of the file system as the page containing the mgiListFolder tag are listed in comma-delimited format.

<mgiListFolder folderLocation="Images">

In this example, the files and folders in the "Images" folder are listed in comma-delimited format.

<mgiListFolder folderLocation="Articles" Delimiter=":">

In this example, the files and folders in the "Articles" folder are listed with a colon delimiter.

<pre>
<mgiListFolder folderLocation="PDFs" Delimiter="\r" 
resultVariableName="Results">
</pre>

<p>Total Items: <mgiGet name="Results_Length">

In this example, the files and folders in the "PDFs" folder are separated by a carriage return in the list. The total number of items in the list is displayed after the "Total Items" label.

<mgiListFolder filter="*.gif">

In this example, all files from the folder containing the mgiListFolder tag with the .GIF extension in the name will be listed in comma-delimited format.


Suggested Usage

  • Loops
  • Image Displays


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]