WolframLang: List Files (Walk Directory)
Get Dir Content (List File Names)
FileNames[]
-
return a List of all files (and directories) in the current directory. Each item is a path.
FileNames[]
FileNames[strPattern]
-
list files of current dir whose name match a string pattern.
The pattern can be a wildcard pattern or regex
Example:
FileNames["*.html"]
for all html files. FileNames[{strPattern1, strPattern2, etc}]
-
match any of the patterns.
FileNames[ALL, dir]
-
all files in a given dir.
FileNames[strPatterns, dir]
-
any of the patterns.
FileNames[strPatterns, dirList]
-
any of the patterns from any of the given dir.
FileNames[strPatterns, dir, n]
-
to depth n.
(the filepath can be relative.)
List Files of Dir and Subdirs (recurse)
List all files, including any subdirectories to infinite depth:
FileNames[ All, "c:/Users/xah/Downloads/" , Infinity]
up to depth 2:
FileNames[ All, "c:/Users/xah/Downloads/" , 2]
List Files, Filter by File Extension
list all file names ending in .html:
FileNames["*.html","c:/Users/xah/web/"]
filter by multiple extensions:
FileNames[ {"*.html", "*.css"}, "c:/Users/xah/"]
List Files of Multiple Directories
list all file names ending in .html or .css, in several directories:
FileNames[ {"*.html", "*.css"}, {"c:/Users/xah/Documents/", "c:/Users/xah/Downloads/"}]
Map Function to Files
WolframLang, Shell Tasks
- WolframScript Tutorial
- WolframLang: File Name Extension
- WolframLang: Shell Tasks
- WolframLang: Navigate Directory
- WolframLang: List Files (Walk Directory)
- WolframLang: File Path Functions
- WolframLang: Delete Dir
- WolframLang: is File or Dir
- WolframLang: File Exist
- WolframLang: Get File Date
- WolframLang: Get File Size
- WolframLang: Print File Content
- WolframLang: Get File Hash
- WolframLang: Read File
- WolframLang: Write File
- WolframLang: Load a Package or File
- WolframLang: Get Environment Variable
- WolframLang: Date Time
- WolframLang: Find/Replace Script