FileSystemMap[f,root]
gives an association whose keys are the names of files in root, and whose values are the results of applying f to the full names of these files.
FileSystemMap[f,root,n]
gives a nested association in which subdirectories down to level n are represented by an association.
FileSystemMap[f,root,{m,n}]
gives a nested association including files in subdirectories from level m down through n.
FileSystemMap[f,root,lev,r]
combines levels to give a nested output association with r levels.
FileSystemMap
FileSystemMap[f,root]
gives an association whose keys are the names of files in root, and whose values are the results of applying f to the full names of these files.
FileSystemMap[f,root,n]
gives a nested association in which subdirectories down to level n are represented by an association.
FileSystemMap[f,root,{m,n}]
gives a nested association including files in subdirectories from level m down through n.
FileSystemMap[f,root,lev,r]
combines levels to give a nested output association with r levels.
Details and Options
- The following options can be given:
-
IncludeDirectories False whether to return f[directory] FileNameForms All include files with names of the specified forms MaxItems Infinity maximum items to include from a directory - FileNameForms will accept any forms specification allowed in the first argument of FileNames.
Examples
open all close allBasic Examples (3)
Apply FileSize to all files contained in a directory:
dir = CreateDirectory[];
ExtractArchive["http://exampledata.wolfram.com/sdtsdlg.tar.gz", dir];FileSystemMap[FileSize, dir]DeleteDirectory[dir, DeleteContents -> True];Apply FileHash to all files through level 2 of the specified directory:
FileSystemMap[FileHash, $UserBaseDirectory, 2]Apply FileDate to only those files at level 2 of the specified directory:
FileSystemMap[FileDate, FileNameJoin[{$InstallationDirectory, "AddOns", "ExtraPackages"}], {2}]Get a flat association for the same directory:
FileSystemMap[FileDate, FileNameJoin[{$InstallationDirectory, "AddOns", "ExtraPackages"}], {2}, 1]Options (3)
FileNameForms (1)
By default, all files are included:
FileSystemMap[FileSize, FileNameJoin[{$InstallationDirectory, "/Documentation/English/System/ExampleData"}]]By specifying FileNameForms->patt, function application will be restricted to only those files that match the specified pattern:
FileSystemMap[FileSize, FileNameJoin[{$InstallationDirectory, "/Documentation/English/System/ExampleData"}], FileNameForms -> "*.pdb"]MaxItems (1)
By default, f will be applied to all files in the specified directory and subdirectories:
FileSystemMap[FileSize, FileNameJoin[{$InstallationDirectory, "SystemFiles", "CharacterEncodings"}]]By specifying MaxItems -> n, f will be applied to at most n items within each directory:
FileSystemMap[FileSize, FileNameJoin[{$InstallationDirectory, "SystemFiles", "CharacterEncodings"}], MaxItems -> 2]IncludeDirectories (1)
By default, the function f is not applied to directories:
FileSystemMap[FileDate, $BaseDirectory, 2]By specifying IncludeDirectories -> True, values for each directory will be included, using the key All:
FileSystemMap[FileDate, $BaseDirectory, 2, IncludeDirectories -> True]See Also
FileSystemScan FileNames Map MaxItems FileNameForms ParallelMap CreateSearchIndex CreateArchive ExtractArchive FileConvert FileSize DeleteDirectory
Function Repository: FileSystemCompare ExploreDirectory
Related Guides
Related Workflows
- Analyze Files in a Directory ▪
- Operate on Files in a Directory
Text
Wolfram Research (2016), FileSystemMap, Wolfram Language function, https://reference.wolfram.com/language/ref/FileSystemMap.html (updated 2019).
CMS
Wolfram Language. 2016. "FileSystemMap." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/FileSystemMap.html.
APA
Wolfram Language. (2016). FileSystemMap. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileSystemMap.html
BibTeX
@misc{reference.wolfram_2026_filesystemmap, author="Wolfram Research", title="{FileSystemMap}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/FileSystemMap.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_filesystemmap, organization={Wolfram Research}, title={FileSystemMap}, year={2019}, url={https://reference.wolfram.com/language/ref/FileSystemMap.html}, note=[Accessed: 15-June-2026]}