File operations
File name operations
a/b/c | a/b/c.txt | |
---|---|---|
FileNameSplit | {a, b, c} | {a, b, c.txt} |
FileBaseName | c | c |
FileExtension | txt | |
FileNameTake | c | c.txt |
FileNameDrop | a/b | a/b |
DirectoryName | a/b/ | a/b/ |
FileNameSplit[file_]
- split the file path into a list of path elements.
FileBaseName[file_]
- return the file name.
FileExtension[file_]
- return the file extension.
FileNameTake|FileNameDrop[file_]
- Take|Drop
for file path.
DirectoryName[file_]
- return the directory path.
FileNameJoin[list_]
- join the list of path elements into a file path according to the operating system.
File operations
a/b/c | a/b/c.txt | /Downloads/test/sub1 | /Downloads/test/sub1/file1.txt | |
---|---|---|---|---|
FileExistsQ | False | False | True | True |
FileType | None | None | Directory | File |
FileFormat | $Failed | $Failed | Directory | Text |
DirectoryQ | False | False | True | False |
ParentDirectory | ParentDirectory["a/b/c"] | ParentDirectory["a/b/c.txt"] | /Downloads/test | ParentDirectory["/Downloads/test/sub1/file1.txt"] |
FileExistsQ[file_]
- test whether a file exists.
FileType[file_]
- return File|Directory
or None
if the file does not exist.
FileFormat[file_]
- try to return the file type.
DirectoryQ[file_]
- return True
if the input is an existing directory, and return False
if the input is not a directory or the directory does not exist.
ParentDirectory[dir_]
- check existence of the directory and and return the parent directory.
CreateFile|DeleteFile|CopyFile|RenameFile[file_]
CreateDirectory|DeleteDirectory|CopyDirectory|RenameDirectory[dir_]
FileNames[forms_,dirs_,depth_]
- return a list of file paths in the directories.
FileSystemMap|FileSystemScan[f_,dir_]
- Map|Scan
for files.
FileSystemTree[dir_]
- return the file tree.
Directories
NotebookDirectory[]
- current notebook directory.
$HomeDirectory
- home directory.
$TemporaryDirectory
- system temporary directory.
$UserBaseDirectory
- directory for user-specific add-on files.
$UserBasePacletsDirectory
- directory for user-specific paclet files.
$Path
- the list of directories to find an external file.
Directory[]
- return the working directory.
SetDirectory[dir_]
- set the working directory.
ResetDirectory[]
- revert to the previous working directory.