Wolfram Language & System 10.4 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


lists all files in the current working directory.

lists all files in the current working directory whose names match the string pattern form.

lists all files whose names match any of the .

lists files with names matching forms in any of the directories .

includes files that are in subdirectories up to n levels down.

Details and OptionsDetails and Options

  • File names can be given as literal strings, StringExpression string patterns, RegularExpression objects, or abbreviated string patterns.
  • In abbreviated string patterns, stands for any sequence of zero or more characters. stands for any sequence of one or more characters other than uppercase letters.
  • FileNames["*"] or FileNames[__] is equivalent to FileNames[].
  • All can also be used in place of .
  • In abbreviated string patterns, Verbatim["s"] specifies that the string should be matched with and treated literally.
  • FileNames[forms,dirs,Infinity] looks for files in all subdirectories of the dirs.
  • The list of files returned by FileNames is sorted in the order generated by the function Sort.
  • FileNames[forms,dirs,{n}] includes names of directories only if they appear exactly at level n.
  • The forms can include relative or absolute directory specifications, in addition to names of files.
  • Setting the option IgnoreCase->True makes FileNames treat lowercase and uppercase letters in file names as equivalent.
  • With the default setting IgnoreCase->Automatic, FileNames treats lowercase and uppercase letters in file names as equivalent under Microsoft Windows operating systems, but not elsewhere.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

List the file and directory names in the $InstallationDirectory:

Click for copyable input
Click for copyable input

Count the files in the whole installation directory:

Click for copyable input
Introduced in 1991
| Updated in 2007