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:
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:
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:
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:
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:
|
|
|
|
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