FileSystem.jl
This module implements utilities for working with files and directories.
It is a complement to the standard Julia FileSystem module.
| Function | Description |
|---|---|
Eegle.FileSystem.fileBase | get a file path without the extension |
Eegle.FileSystem.fileExt | extract the extension from a file name, including the dot |
Eegle.FileSystem.changeFileExt | change the extension of a file |
Eegle.FileSystem.getFilesInDir | search for files in a directory and its subdirectories |
Eegle.FileSystem.getFoldersInDir | search for directories in a directory and its subdirectories |
📖
Eegle.FileSystem.fileBase — Function
function fileBase(file::String)Return file, including the complete path, without the extension.
Example
fileBase(joinpath(homedir(), "myfile.txt"))
# return (joinpath(homedir(), "myfile"))Eegle.FileSystem.fileExt — Function
function fileExt(file::String)Return the extension of a file, including the dot.
Example
fileExt(joinpath(homedir(), "myfile.txt"))
# return ".txt" Eegle.FileSystem.changeFileExt — Function
function changeFileExt(file::String, ext::String)Return the complete path of file with extension changed to ext.
Example
changeFileExt(joinpath(homedir(), "myfile.txt"), ".csv")
# return joinpath(homedir(), "myfile.csv")Eegle.FileSystem.getFilesInDir — Function
function getFilesInDir(dir::Union{String, Vector{String}};
ext::Tuple=(), isin::String="")Return a vector of strings comprising the complete path of all files in directory dir.
Arguments
dir, which can be a directory or a vector of directories.
Optional Keyword Arguments
extis an optional tuple of file extensions. If it is provided, return only the files with those extensions. The extensions must be entered in lowercase.- If a string is provided as
isin, return only those files whose name contains the string.
Examples
using Eegle # or using Eegle.FileSystem
S=getFilesInDir(@__DIR__) # start at current directory.
S=getFilesInDir(@__DIR__; ext=(".txt", ))
S=getFilesInDir(@__DIR__; ext=(".txt", ".jl"), isin="Analysis")Eegle.FileSystem.getFoldersInDir — Function
function getFoldersInDir(dir::String; isin::String="")Return a vector of strings comprising the complete path of all directories in directory dir.
If a string is provided as kwarg isin, return only the directories whose name contains the string.
Examples
using Eegle # or using Eegle.FileSystem
S=getFoldersInDir(@__DIR__)
S=getFoldersInDir(@__DIR__; isin="Analysis")