ListDirectory - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


FileTools

  

ListDirectory

  

display the contents of a directory

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

ListDirectory(dir, opts )

Parameters

dir

-

path to the directory to be displayed

opts

-

(optional) argument of the form option or option=value where option is one of absolute, all, base, long, recurse, remove, returnonly, or select

Options

• 

ListDirectory accepts these optional arguments: absolute, all, base, depth, long, recurse, remove, returnonly, and select.

• 

absolute=truefalse

  

Specifying absolute=true causes ListDirectory to return absolute paths for all listed files (see AbsolutePath). With the default value absolute=false, only the filenames themselves are returned.

• 

all=truefalse

  

By default, ListDirectory does not include filenames that begin with "." in its list of results. Specifying the all option causes ListDirectory to include these files.

• 

base=one of bindir, datadir, homedir, mapledir, tempdir, toolboxdir, worksheetdir.

  

The base option specifies a base directory. If specified, the parameter dir is interpreted as a relative path under this directory. For the meaning of worksheetdir see interface; for any other of these symbols, see kernelopts.

• 

depth=posint or infinity

  

Specifying depth with a value other than 1 causes ListDirectory to recursively traverse the complete directory tree starting with dir to the depth specified by depth.

  

Note that if depth is set to a value other than 1, the value of option absolute is implicitly set to true, and the special directories "." and ".." will not appear in the list of results even if all=true was specified.

  

Specifying depth=infinity is equivalent to specifying recurse=true.

• 

long=truefalse

  

Specifying long causes ListDirectory to returns a DataFrame structure which contains the name together with additional properties about each file, including size, whether or not the file is a directory, access permissions, and last modification date. The default is false.

• 

recurse=truefalse

  

Specifying recurse=true causes ListDirectory to recursively traverse the complete directory tree starting with dir. The default is false.

  

Note that if recurse=true, the value of option absolute is set to true, and the special directories "." and ".." will not appear in the list of results even if all=true was specified.

  

Specifying recurse=true is equivalent to specifying depth=infinity.

• 

remove=string

  

The remove option is used to remove elements from the list of filenames. Only the filenames that do not match the pattern specified in the string are returned. The pattern must conform to the form defined by StringTools[WildcardMatch].

• 

returnonly=string

  

The returnonly option is an alias for the select option.

• 

select=string

  

The select option is used to select elements from the list of filenames. Only the filenames that match the pattern specified in the string are returned. The pattern must conform to the form defined by StringTools[WildcardMatch].

Description

• 

The ListDirectory(dir) calling sequence returns the contents of the directory dir as a list.

• 

If dir does not exist, ListDirectory generates an error.

• 

If dir is not a directory, ListDirectory generates an error.

• 

For information on filenames, see file.

Examples

DataDirectoryFileToolsJoinPathdata,base=mapledir

DataDirectory/maple/cbat/active/268316/data

(1)

FileToolsListDirectoryDataDirectory

Excel,FMUs,CAD,GroupData,SQLite,Start.mw,StudyGuides,ThermophysicalData,Workbook,datasets,dsolve,assistants,audio,eBookTools,example,finance,help,images,ks.txt,plotting,portal,sigpro,stylesets,tutors,videos,xls,xml,xsl,zoneinfo

(2)

FileToolsListDirectoryDataDirectory,all

.,..,Excel,FMUs,CAD,GroupData,SQLite,Start.mw,StudyGuides,ThermophysicalData,Workbook,datasets,dsolve,assistants,audio,eBookTools,example,finance,help,images,ks.txt,plotting,portal,sigpro,stylesets,tutors,videos,xls,xml,xsl,zoneinfo

(3)

FileToolsListDirectoryDataDirectory,all,select=f*

finance

(4)

FileToolsListDirectoryDataDirectory,select=*[ae]*

Excel,GroupData,SQLite,Start.mw,StudyGuides,ThermophysicalData,datasets,dsolve,assistants,audio,eBookTools,example,finance,help,images,portal,stylesets,videos,zoneinfo

(5)

FileToolsListDirectoryDataDirectory,all,select=*[ae]*

Excel,GroupData,SQLite,Start.mw,StudyGuides,ThermophysicalData,datasets,dsolve,assistants,audio,eBookTools,example,finance,help,images,portal,stylesets,videos,zoneinfo

(6)

FileToolsListDirectory/home/maple/m/foo1.m

Error, (in listdir) directory does not exist

FileToolsListDirectory/home/maple/noexist

Error, (in isdir) file or directory does not exist

Compatibility

• 

The depth, long and recurse options were introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

• 

The base option was introduced in Maple 2020.

• 

For more information on Maple 2020 changes, see Updates in Maple 2020.

• 

The FileTools[ListDirectory] command was updated in Maple 2024.

• 

The remove and select options were introduced in Maple 2024.

• 

For more information on Maple 2024 changes, see Updates in Maple 2024.

See Also

file

FileTools[AbsolutePath]

FileTools[Binary][Open]

FileTools[IsDirectory]

FileTools[Text][Open]

IO_errors

StringTools[WildcardMatch]