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

Examples

open allclose all

Basic Examples  (3)

Apply FileSize to all files contained in a directory:

Apply FileHash to all files through level 2 of the specified directory:

Apply FileDate to only those files at level 2 of the specified directory:

Get a flat association for the same directory:

Options  (2)

FileNameForms  (1)

By default, all files are included:

By specifying FileNameForms->patt, function application will be restricted to only those files that match the specified pattern:

MaxItems  (1)

By default, f will be applied to all files in the specified directory and subdirectories:

By specifying MaxItems -> n, f will be applied to at most n items within each directory:

Possible Issues  (1)

When specifying a fixed number of association levels, empty directories will be omitted from the resulting association:

Introduced in 2016
 (11.0)
 |
Updated in 2019
 (12.0)