Mathematica 9 is now available
Previous section-----Next section

2.12.6 Manipulating Files and Directories

CopyFile[" ", " "] copy  to
RenameFile[" ", " "] 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 File, 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 {year, month, day, hour, minute, second} format used by Date.

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[" ", " "]
rename a directory
CopyDirectory[" ", " "] copy a directory and all the files in it

Functions for manipulating directories.


Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.