Manipulating Files and Directories

CopyFile["file1","file2"]copy to
RenameFile["file1","file2"]give the name
DeleteFile["file"]delete a file
FileByteCount["file"]give the number of bytes in a file
FileDate["file"]give the modification date for a file
SetFileDate["file"]set the modification date for a file to be the current date
FileType["file"]give the type of a file as , Directory, or None

Functions for manipulating files.

Different operating systems have different commands for manipulating files. Mathematica provides a simple set of file manipulation functions, intended to work in the same way under all operating systems.

Notice that CopyFile and RenameFile give the final file the same modification date as the original one. FileDate returns modification dates in the format used by DateList.

CreateDirectory["name"]create a new directory
DeleteDirectory["name"]delete an empty directory
DeleteDirectory["name",DeleteContents->True]delete a directory and all files and directories it contains
RenameDirectory["name1","name2"]rename a directory
CopyDirectory["name1","name2"]copy a directory and all the files in it

Functions for manipulating directories.

New to Mathematica? Find your learning path »
Have a question? Ask support »