DeleteFile["file"]
deletes a file.
DeleteFile[{"file1","file2",…}]
deletes a list of files.
DeleteFile
DeleteFile["file"]
deletes a file.
DeleteFile[{"file1","file2",…}]
deletes a list of files.
Details
- DeleteFile returns Null if it succeeds in deleting files, and $Failed if it fails.
- File["path"] may be used to specify a file name.
- DeleteFile[CloudObject[…]] deletes cloud objects that correspond to files.
Examples
open all close allBasic Examples (1)
Copy a file into the temporary directory:
src = $InstallationDirectory <> "/Documentation/English/System/ExampleData/coneflower.jpg";
dst = FileNameJoin[{$TemporaryDirectory, "coneflower.jpg"}];
CopyFile[src, dst]FileNames[dst]DeleteFile[dst]FileNames[dst]Scope (3)
Copy a file specified as a File object:
file = $InstallationDirectory <> "/Documentation/English/System/ExampleData/coneflower.jpg";
cfile = FileNameJoin[{$TemporaryDirectory, "coneflower.jpg"}];CopyFile[File[file], File[cfile]]Delete a file specified as a File object
DeleteFile[File[cfile]]Create multiple temporary files:
Table[CreateFile[], {3}]Delete them all simultaneously:
DeleteFile[%]obj = CloudPut[10!]Check that the file type of the object is File:
FileType[obj]DeleteFile[obj]Properties & Relations (2)
Put[0, LocalObject["zero"]]DeleteObject[LocalObject["zero"]]PersistentSymbol["one", "KernelSession"] = 1;DeleteObject[PersistentObject["one", "KernelSession"]]Alternatively, use Remove on the persistent symbol:
PersistentSymbol["one", "KernelSession"] = 1;Remove[PersistentSymbol["one", "KernelSession"]]Tech Notes
Related Guides
History
Introduced in 1991 (2.0) | Updated in 2016 (11.0)
Text
Wolfram Research (1991), DeleteFile, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteFile.html (updated 2016).
CMS
Wolfram Language. 1991. "DeleteFile." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/DeleteFile.html.
APA
Wolfram Language. (1991). DeleteFile. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeleteFile.html
BibTeX
@misc{reference.wolfram_2026_deletefile, author="Wolfram Research", title="{DeleteFile}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/DeleteFile.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_deletefile, organization={Wolfram Research}, title={DeleteFile}, year={2016}, url={https://reference.wolfram.com/language/ref/DeleteFile.html}, note=[Accessed: 12-June-2026]}