# 6.7.31 SHOW DIRECTORY

Part of: [6 Language](6-language.md) › [6.7 Data Introspection Language (DIL)](6-7-data-introspection-language-dil.md)

### Syntax

**SHOW** **DIRECTORY** [_directory_name_] [**LIKE** _regular_expression_ [**DEEP** {_deep_value_ | {[_deep_value_] {**,** [_deep_value_]}+}} [**SKIP**]]\
[_post_processing_option_]\
[_output_redirecting_option_]

### Description

Show (i.e. get) the directories within a directory named _directory_name_ or check for the existence of a directory named _directory_name_. If _directory_name_ is not specified, all directories within the directory currently in use are returned. Otherwise, if _directory_name_ is specified and the keyword LIKE is not specified, one of the following behaviors applies:

- If it ends with “/”, all directories within _directory_name_ are returned.
- If it does not end with “/”, _directory_name_ will be checked for existence as a directory. If it exists, _directory_name_ is returned; otherwise, if it does not exist, an error is raised.

In case the keyword LIKE is specified, only directories with names complying with a regular expression named _regular_expression_ will be returned (in HDFql, regular expressions are the ones specified by PCRE, which closely follows Perl 5 syntax – please refer to [https://www.pcre.org](https://www.pcre.org/) and <https://perldoc.perl.org/perlre> for additional information). As a general rule, in case _regular_expression_ contains spaces or special characters, it should be enclosed in double quotes (“). Otherwise, if it is not enclosed in double quotes, directories are not returned, and an error is raised. If _regular_expression_ includes “\*\*”, a recursive search is performed (i.e. HDFql will search in all existing directories and subdirectories for directories to return). If _directory_name_ is specified, the recursive search starts from within _directory_name_, which is assumed to be a directory. To limit the recursiveness, the keyword DEEP may be specified along with a value _deep_value_ that represents the maximum recursiveness limit. In case the keyword SKIP is specified, HDFql will skip (i.e. ignore) a directory that cannot be opened (due to, e.g., permission restrictions) and continue searching (instead of stopping and raising an error).

### Parameter(s)

_directory_name_ – optional string that specifies the name of the directory within which to show (i.e. get) existing subdirectories or to check for the existence of the directory.

regular_expression – optional string that specifies the regular expression with which the names of directories must comply for those directories to be returned. If regular_expression includes “\*\*”, a recursive search is performed.

_deep_value_ – optional integer that specifies the maximum recursiveness limit (i.e. how deep the recursive search is performed). If _deep_value_ is specified, it must be equal to or greater than 0 (otherwise an error is raised).

_post_processing_option_ – optional option that transforms the result set according to the programmer’s needs, such as ordering or truncating (please refer to the section [PROCESSING](6-2-processing.md) for additional information).

_output_redirecting_option_ – optional option that specifies the cursor in use, an HDF5 object (i.e. dataset or attribute), a (text, binary, or Excel) file, or memory (i.e. user-defined variable) to write the result set into (please refer to the subsection [INTO](6-3-2-into.md) for additional information). If not specified, the cursor in use is populated with the result set instead (please refer to the chapter [CURSOR](4-cursor.md) for additional information).

### Return

The directory names within a directory or the existence of a directory as an [HDFQL_VARCHAR](5-1-constants.md#hdfql_varchar).

### Example(s)

```hdfql
# create three directories named "my_directory0", "my_directory1", and "my_directory2" within the working directory currently in use
CREATE DIRECTORY my_directory0, my_directory1, my_directory2

# create two directories named "my_subdirectory0" and "my_subdirectory1" within the directory "my_directory0", and a directory named "my_subsubdirectory0" within directory "my_directory0/my_subdirectory1"
CREATE DIRECTORY my_directory0/my_subdirectory0, my_directory0/my_subdirectory1, my_directory0/my_subdirectory1/my_subsubdirectory0

# show (i.e. get) directories within the working directory currently in use (should return "my_directory0", "my_directory1", and "my_directory2")
SHOW DIRECTORY

# show (i.e. get) directories within directory "my_directory0" (should return "my_subdirectory0" and "my_subdirectory1")
SHOW DIRECTORY my_directory0/

# show (i.e. get) directories within the working directory currently in use and within subdirectories recursively (should return "my_directory0", "my_directory1", "my_directory2", "my_directory0/my_subdirectory0", "my_directory0/my_subdirectory1", and "my_directory0/my_subdirectory1/my_subsubdirectory0")
SHOW DIRECTORY LIKE **

# show (i.e. get) directories that contain "directory1" in their names within the working directory currently in use and within subdirectories recursively (should return "my_directory1" and "my_directory0/my_subdirectory1")
SHOW DIRECTORY LIKE **/directory1

# show (i.e. get) directories within directory "my_directory0" and within subdirectories recursively (should return "my_subdirectory0", "my_subdirectory1", and "my_subdirectory1/my_subsubdirectory0")
SHOW DIRECTORY my_directory0/ LIKE **

# check for the existence of a directory named "my_directory0" within the working directory currently in use (should return "my_directory0" (i.e. it exists))
SHOW DIRECTORY my_directory0
```
