File Exchange

image thumbnail


version 1.2.1 (25.4 KB) by Martin Koch
Classes for convenient handling of filesystem paths


Updated 03 Mar 2021

From GitHub

View Version History

View license on GitHub

This package aims so make everything you ever needed to do with a path less tedious and produce readable code in the process. It consists of the File and Folder classes, which represent filesystem paths and provide extensive functionality for extracting path properties, manipulate and combine paths and interact with the filesystem.

- Get and set path properties like root, stem and extension
- Filter paths by extension, name, etc. using wildcards
- List files recursively
- Handle lists of paths
- Clean and resolve paths depening on the OS
- Build absolute or relative paths
- Automatically create folder when writing files and throw error on failure
- Chain methods together, creating effective but readable code
- Get folder of currently executing MATLAB file

You can find the documentation in the GitHub repo and examples here in the "Examples" tab.

>> personalFolders = Folder("astronauts") / ["Andrew", "Trudy", "Sniffels"]


>> personalFolders.append("DONT_PANIC.txt").createEmptyFile;

>> files = Folder("Sketchy Folder").listDeepFiles

File("Sketchy Folder\DeleteStuffVirus.exe")
File("Sketchy Folder\System32\nastyworm.dll")
File("Sketchy Folder\dark_corner\half_a_sandwich.dat")
File("Sketchy Folder\WormholeResearch.pdf")

>> files.whereStemIs(["*Virus*", "*Worm*"]).whereExtensionIsNot(".pdf").copyToFolder("D:\Quarantine");

>> scriptFile = File.ofCaller

File("/MATLAB Drive/YesIMadeAnExtraScriptToDemonstrateThis.m")


Cite As

Martin Koch (2021). Path (, GitHub. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2020b
Compatible with R2019b and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!