Wolfram: 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[] (* sample output {detect_zero_vector.html, Elementary_Intro_to_Wolfram_Language_Review.html, history_of_notebook.html, i, ic, index.html, lisp_macro_vs_WolframLang.html, lisp_root_of_wolfram_lang.html, lisp_vs_WolframLang.html, Mathematica_logo, Mathematica_logo.html, ...} *)
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 Scripting Tasks
- Wolfram: Shell Scripting Tasks
- Wolfram: Navigate Directory
- Wolfram: List Files (Walk Directory)
- Wolfram: File Path Functions
- Wolfram: Delete Dir
- Wolfram: is File or Dir
- Wolfram: File Exist
- Wolfram: Get File Date
- Wolfram: Get File Size
- Wolfram: Print File Content
- Wolfram: Get File Hash
- Wolfram: Read File
- Wolfram: Read File from Web
- Wolfram: Write File
- Wolfram: Load a Package or File
- Wolfram: Get Environment Variable
- Wolfram: Date Time
- Wolfram: Find Replace Script