FileExistsQ["name"]
gives True if the file with the specified name exists, and gives False otherwise.
FileExistsQ
FileExistsQ["name"]
gives True if the file with the specified name exists, and gives False otherwise.
Details
- In FileExistsQ["name"], name is interpreted relative to your current directory.
- FileExistsQ does not search $Path.
- FileExistsQ tests for files, directories, or any other filesystem objects.
- FileExistsQ also works with cloud objects.
- FileExistsQ[File["file"]] is also supported
Examples
open all close allBasic Examples (2)
FileExistsQ[FileNameJoin[{$TemporaryDirectory, "temp.txt"}]]Put[FileNameJoin[{$TemporaryDirectory, "temp.txt"}]];FileExistsQ[FileNameJoin[{$TemporaryDirectory, "temp.txt"}]]DeleteFile[FileNameJoin[{$TemporaryDirectory, "temp.txt"}]]Scope (2)
Check if the file specified by the File object exists:
file = CreateFile[];FileExistsQ[File[file]]Create a reference to a new anonymous cloud object:
obj = CloudObject[]The cloud object does not yet exist in the Wolfram Cloud:
FileExistsQ[obj]Create the cloud object by putting an expression in it:
CloudPut[10!, obj];Now the cloud object exists in the Wolfram Cloud:
FileExistsQ[obj]DeleteFile[obj]The cloud object no longer exists:
FileExistsQ[obj]See Also
FindFile AbsoluteFileName DirectoryQ Put File CloudObject
Function Repository: ObjectExistsQ EnsureFilePath ObjectIfExists
Related Guides
Text
Wolfram Research (2008), FileExistsQ, Wolfram Language function, https://reference.wolfram.com/language/ref/FileExistsQ.html (updated 2016).
CMS
Wolfram Language. 2008. "FileExistsQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/FileExistsQ.html.
APA
Wolfram Language. (2008). FileExistsQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileExistsQ.html
BibTeX
@misc{reference.wolfram_2026_fileexistsq, author="Wolfram Research", title="{FileExistsQ}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/FileExistsQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_fileexistsq, organization={Wolfram Research}, title={FileExistsQ}, year={2016}, url={https://reference.wolfram.com/language/ref/FileExistsQ.html}, note=[Accessed: 13-June-2026]}