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.
Features:
- 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.
Examples:
-----------------------------------------------------------------------------------------------
>> personalFolders = Folder("astronauts") / ["Andrew", "Trudy", "Sniffels"]
Folder("astronauts\Andrew")
Folder("astronauts\Trudy")
Folder("astronauts\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")
>> scriptFile.parent.cd;
Martin Koch (2021). Path (https://github.com/MartinKoch123/Path/releases/tag/v1.2.1), GitHub. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.