({{, (RefLink[FileNames, paclet:ref/FileNames])[]
lists all files in the current working directory. }, {, (RefLink[FileNames, paclet:ref/FileNames])[form]
lists all files in the current working directory whose names match the string pattern form. }, {, (RefLink[FileNames, paclet:ref/FileNames])[{(Subscript[form, 1]),(Subscript[form, 2]),…}]
lists all files whose names match any of the (Subscript[form, i]). }, {, (RefLink[FileNames, paclet:ref/FileNames])[(RefLink[All, paclet:ref/All]),dir]
lists all files in the directory dir.}, {, (RefLink[FileNames, paclet:ref/FileNames])[forms,{(Subscript[dir, 1]),(Subscript[dir, 2]),…}]
lists files with names matching forms in any of the directories (Subscript[dir, i]). }, {, (RefLink[FileNames, paclet:ref/FileNames])[forms,dirs,n]
includes files that are in subdirectories up to n levels down. }})

OpenersNotesSection(Spacer1)Details and Options

File names can be given as literal strings, (RefLink[StringExpression, paclet:ref/StringExpression]) string patterns, (RefLink[RegularExpression, paclet:ref/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.

(RefLink[FileNames, paclet:ref/FileNames])[(RefLink[All, paclet:ref/All])], (RefLink[FileNames, paclet:ref/FileNames])["*"], or (RefLink[FileNames, paclet:ref/FileNames])[__] is equivalent to (RefLink[FileNames, paclet:ref/FileNames])[].

In abbreviated string patterns, (RefLink[Verbatim, paclet:ref/Verbatim])["s"] specifies that the string "s" should be matched with * and @ treated literally.

(RefLink[FileNames, paclet:ref/FileNames])[forms,dirs,(RefLink[Infinity, paclet:ref/Infinity])] looks for files in all subdirectories of the dirs.

The list of files returned by (RefLink[FileNames, paclet:ref/FileNames]) is sorted in the order generated by the function (RefLink[Sort, paclet:ref/Sort]).

(RefLink[FileNames, paclet:ref/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 (RefLink[IgnoreCase, paclet:ref/IgnoreCase])->(RefLink[True, paclet:ref/True]) makes (RefLink[FileNames, paclet:ref/FileNames]) treat lowercase and uppercase letters in file names as equivalent.

With the default setting (RefLink[IgnoreCase, paclet:ref/IgnoreCase])->(RefLink[Automatic, paclet:ref/Automatic]), (RefLink[FileNames, paclet:ref/FileNames]) treats lowercase and uppercase letters in file names as equivalent under Microsoft Windows operating systems, but not elsewhere.

(RefLink[File, paclet:ref/File])["dir"] may be used to specify a literal directory name to search.

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

List the file and directory names in the (RefLink[$InstallationDirectory, paclet:ref/$InstallationDirectory]):

SetDirectory[$InstallationDirectory];

FileNames[]

Count the files in the whole installation directory:

FileNames[All,$InstallationDirectory,Infinity]//Length

OpenersExampleSection1(Spacer1)Scope  (1)

List files in the directory specified by the (RefLink[File, paclet:ref/File]) object:

FileNames[All,File[$InstallationDirectory]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FileNameSetter, paclet:ref/FileNameSetter])  ▪  (RefLink[SystemDialogInput, paclet:ref/SystemDialogInput])  ▪  (RefLink[Directory, paclet:ref/Directory])  ▪  (RefLink[FindFile, paclet:ref/FindFile])  ▪  (RefLink[FileConvert, paclet:ref/FileConvert])  ▪  (RefLink[FileType, paclet:ref/FileType])  ▪  (RefLink[FileDate, paclet:ref/FileDate])  ▪  (RefLink[FileSize, paclet:ref/FileSize])  ▪  (RefLink[FileHash, paclet:ref/FileHash])  ▪  (RefLink[FilePrint, paclet:ref/FilePrint])  ▪  (RefLink[Get, paclet:ref/Get])  ▪  (RefLink[CloudObjects, paclet:ref/CloudObjects])  ▪  (RefLink[FileSystemMap, paclet:ref/FileSystemMap])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Naming and Finding Files, paclet:tutorial/NamingAndFindingFiles])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[File Operations, paclet:guide/FileOperations])}, {▪(RefLinkPlain[Importing and Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Operations on File Names, paclet:guide/OperationsOnFileNames])}, {▪(RefLinkPlain[Files, paclet:guide/Files])}, {▪(RefLinkPlain[External Operations, paclet:guide/ExternalOperations])}, {▪(RefLinkPlain[Managing Content in the Cloud, paclet:guide/ManagingContentInTheCloud])}, {▪(RefLinkPlain[Wolfram System Session Information, paclet:guide/WolframSystemSessionInformation])}})}})