Wolfram Language

Systems-Level Functionality

Recursively Search through Directories

FileSystemMap will normally evaluate on all files in a given directory.

show complete Wolfram Language input
In[1]:=
Click for copyable input
dir = FileNameJoin[{$InstallationDirectory, "SystemFiles", "SpellingDictionaries"}];
In[2]:=
Click for copyable input
Length[Keys[FileSystemMap[FileByteCount, dir]]]
Out[2]=

FileNameForms allows you to select files with a specific pattern in FileSystemMap.

In[3]:=
Click for copyable input
FileSystemMap[FileByteCount, dir, FileNameForms -> "*en*"]
Out[3]=
In[4]:=
Click for copyable input
FileSystemMap[FileByteCount, dir, FileNameForms -> "*en*"]; Length[Keys[%]]
Out[4]=

Use FileSystemScan with FileNameForms to copy all documentation pages with "Date" in the title to a new directory.

show complete Wolfram Language input
In[5]:=
Click for copyable input
targetDir = CreateDirectory[FileNameJoin[{$TemporaryDirectory, "new"}]]; docsDir = FileNameJoin[{$InstallationDirectory, "Documentation", "English", "System", "ReferencePages", "Symbols"}];
In[6]:=
Click for copyable input
copy[file_] := CopyFile[file, FileNameJoin[{targetDir, FileNameTake[file, -1]}]]
In[7]:=
Click for copyable input
FileNames["*", targetDir]
Out[7]=
In[8]:=
Click for copyable input
FileSystemScan[copy, docsDir, Infinity, FileNameForms -> "*Date*.nb"]
In[9]:=
Click for copyable input
FileNames["*", targetDir]
Out[9]=

These files can also be removed using FileSystemScan.

In[10]:=
Click for copyable input
FileSystemScan[DeleteFile, targetDir]
In[11]:=
Click for copyable input
FileNames["*", targetDir]
Out[11]=

Related Examples

de es fr ja ko pt-br ru zh