DIRECTORY command

Generates a list of files and folders in the specified directory.

Syntax

DIRECTORY <file_spec> <SUPPRESS> <SUBDIRECTORY> <APPEND> <TO table_name|filename>

Parameters

Name Description
file_spec

optional

The Windows folder or files to list and display information for.

You can use the asterisk wildcard (*) to list all files with a particular extension, all files that start with a particular string, or all files in a folder. For example:

  • *.fil – lists all files with the .fil extension (Analytics data files)
  • Inv*.* – lists all files that begin with "Inv" regardless of what file extension they have
  • Results\* or Results\*.* – lists all files in the Results folder

To limit the files listed to a particular folder, you can specify a path relative to the Analytics project folder, or specify a full path. For example:

  • Results\*.* – displays the contents of the Results subfolder in the Analytics project folder
  • C:\ACL Data\Results\*.* – displays the contents of the specified folder

Note

The wildcard character cannot be used in intermediary levels of a specified file path. It can only be used in the final level of the path, as shown above.

Paths or file names that contain spaces must be enclosed in double quotation marks.

If you use file_spec, it must be placed before any of the other parameters. If file_spec appears in any other position, the DIRECTORY command is not processed and an error is generated.

If you omit file_spec, all files in the folder containing the Analytics project are listed. You cannot use any of the other parameters if you omit file_spec.

SUPPRESS

optional

Suppresses path information in the output, leaving only the file names and properties.

SUBDIRECTORY

optional

Includes the contents of subfolders in the directory listing.

For example, if file_spec specifies Results\*.fil, the Results folder, and all subfolders contained in the Results folder, are searched for .fil files.

Depending on the number of subfolders and files that need to be listed, using SUBDIRECTORY may result in a delay while the subfolders are searched. Analytics displays a dialog box showing progress of the command.

APPEND

optional

Appends the command output to the end of an existing file instead of overwriting it.

Note

You must ensure that the structure of the command output and the existing file are identical:

  • the same fields
  • the same field order
  • matching fields are the same length
  • matching fields are the same data type

Analytics appends output to an existing file regardless of its structure. If the structure of the output and the existing file do not match, jumbled, missing, or inaccurate data can result.

TO table_name | filename

optional

The location to send the results of the command to:

  • table_name saves the results to an Analytics table

    Specify table_name as a quoted string with a .FIL file extension. For example: TO "Output.FIL"

    By default, the table data file (.FIL) is saved to the folder containing the Analytics project.

    Use either an absolute or relative file path to save the data file to a different, existing folder:

    • TO "C:\Output.FIL"
    • TO "Results\Output.FIL"

    Note

    Table names are limited to 64 alphanumeric characters, not including the .FIL extension. The name can include the underscore character ( _ ), but no other special characters, or any spaces. The name cannot start with a number.

  • filename saves the results to a file

    Specify filename as a quoted string with the appropriate file extension. For example: TO "Output.TXT"

    By default, the file is saved to the folder containing the Analytics project.

    Use either an absolute or relative file path to save the file to a different, existing folder:

    • TO "C:\Output.TXT"
    • TO "Results\Output.TXT"

If you omit TO, the directory listing appears in the Analytics display area.

Examples

Different options for listing files

The ability to list files is useful for ad hoc investigation, and for incorporating in scripting.

A number of different options for listing files with the DIRECTORY command appear below.

List all files

Lists all the files in the folder containing the Analytics project:

DIRECTORY

List all the files of a specific type

Lists all the .fil files (Analytics data files) in the folder containing the Analytics project:

DIRECTORY *.fil

Use wildcards to list files

Lists all the file names beginning with "Inv" in the folder containing the Analytics project:

DIRECTORY Inv*.*

List all the files in a subfolder relative to the Analytics project folder

Lists all the files in the Results subfolder in the folder containing the Analytics project:

DIRECTORY "Results\*"

List all the files in a specified folder

Lists all the files in the Results subfolder:

DIRECTORY "C:\ACL Data\Results\*"

List all the files of a specific type in a specified location

Lists all the .fil files (Analytics data files) in the specified folder and any subfolders:

DIRECTORY "C:\ACL Data\Results\*.fil" SUBDIRECTORY

List all the files in a specified folder and output the list to an Analytics table

Lists all the files in the Results folder and outputs the list to an Analytics table in the folder containing the Analytics project:

DIRECTORY "C:\ACL Data\Results\*" TO Results_Folder_Contents.fil

The new table Results_Folder_Contents is added to the open project.

List all the files in one folder and output the list to an Analytics table in another folder

Lists all the files in the ACL Data\Results folder and outputs the list to an Analytics table in the GL Audit 2014\Results folder:

DIRECTORY "C:\ACL Data\Results\*" TO "C:\ACL Projects\GL Audit 2014\Results\Results_Folder_Contents.fil"

The new table Results_Folder_Contents is added to the open project. The associated data file (Results_Folder_Contents.fil) is created in the specified output folder, which may or may not be the folder containing the Analytics project.

Remarks

Properties displayed by DIRECTORY

The DIRECTORY command is similar to the DIR command in Windows. In addition to listing files and subfolders in a folder, the DIRECTORY command also displays the following file and folder properties:

  • File Size
  • Attributes
  • Create Date
  • Create Time
  • Access Date
  • Access Time
  • Modified Date
  • Modified Time
  • the total number of files and folders that match the specified criteria

Uses for DIRECTORY in a script

When used in a script, the DIRECTORY command provides the ability to examine the file system. For example, you could use DIRECTORY in conjunction with other commands to detect the presence or absence of files, check a file's size, or make decisions based on other file properties.

Outputting the results of DIRECTORY

You can run the command from the command line to display a directory listing on screen, or save the listing to an Analytics table or .txt file.

How to open table-based results of DIRECTORY

The DIRECTORY command does not include the OPEN parameter. If you are using the command in a script and outputting the results to an Analytics table, and you want to open the resulting table, follow the DIRECTORY command with the OPEN command. For example:

DIRECTORY "C:\ACL Data\Results\*" TO Results_Folder_Contents.fil 
OPEN Results_Folder_Contents