FileNames
✖
FileNames
Details 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[All], FileNames["*"], or FileNames[__] is equivalent to FileNames[].
- In abbreviated string patterns, Verbatim["s"] specifies that the string "s" 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.
- File["dir"] may be used to specify a literal directory name to search.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
List the file and directory names in the $InstallationDirectory:
In[1]:=1

✖
https://wolfram.com/xid/0bdo9pcqb-n9l788
In[2]:=2

✖
https://wolfram.com/xid/0bdo9pcqb-grbkbv
Out[2]=2

Count the files in the whole installation directory:
In[3]:=3

✖
https://wolfram.com/xid/0bdo9pcqb-dzocuk
Out[3]=3

Scope (1)Survey of the scope of standard use cases
List files in the directory specified by the File object:
In[1]:=1

✖
https://wolfram.com/xid/0bdo9pcqb-bzvdwh
Out[1]=1

Wolfram Research (1991), FileNames, Wolfram Language function, https://reference.wolfram.com/language/ref/FileNames.html (updated 2019).
✖
Wolfram Research (1991), FileNames, Wolfram Language function, https://reference.wolfram.com/language/ref/FileNames.html (updated 2019).
Text
Wolfram Research (1991), FileNames, Wolfram Language function, https://reference.wolfram.com/language/ref/FileNames.html (updated 2019).
✖
Wolfram Research (1991), FileNames, Wolfram Language function, https://reference.wolfram.com/language/ref/FileNames.html (updated 2019).
CMS
Wolfram Language. 1991. "FileNames." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/FileNames.html.
✖
Wolfram Language. 1991. "FileNames." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/FileNames.html.
APA
Wolfram Language. (1991). FileNames. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileNames.html
✖
Wolfram Language. (1991). FileNames. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileNames.html
BibTeX
✖
@misc{reference.wolfram_2025_filenames, author="Wolfram Research", title="{FileNames}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/FileNames.html}", note=[Accessed: 27-May-2025
]}
BibLaTeX
✖
@online{reference.wolfram_2025_filenames, organization={Wolfram Research}, title={FileNames}, year={2019}, url={https://reference.wolfram.com/language/ref/FileNames.html}, note=[Accessed: 27-May-2025
]}