DeleteObject[obj]
deletes the object obj.
DeleteObject[{obj1,obj2,…}]
deletes all the obji.
DeleteObject
DeleteObject[obj]
deletes the object obj.
DeleteObject[{obj1,obj2,…}]
deletes all the obji.
Details
- DeleteObject returns Null if it succeeds in deleting all given objects, and $Failed otherwise.
- DeleteObject works on objects such as CloudObject, LocalObject, PersistentObject, ResourceObject, ExternalSessionObject and ServiceObject.
- DeleteObject deletes files and directories without asking for confirmation.
Examples
open all close allBasic Examples (2)
Put[0, LocalObject["zero"]]DeleteObject[LocalObject["zero"]]l = Put[0, LocalObject["zero"]]c = CloudPut[0, CloudObject["zero"]]DeleteObject[{l, c}]Scope (12)
PersistentSymbol["one", "KernelSession"] = 1;DeleteObject[PersistentObject["one", "KernelSession"]]Remove all persistent objects with a given key on $ContextPath:
DeleteObject[PersistentObjects["one"]]Remove all persistent objects of a given persistence location:
DeleteObject[PersistenceLocation["KernelSession"]]CloudPut[42, CloudObject["answer"]]DeleteObject[CloudObject["answer"]]Create a directory cloud object:
dir = CreateDirectory[CloudObject["answers"]]Add something to the directory:
CloudPut[42, FileNameJoin[{dir, "problem1"}]]Remove the directory cloud object and its contents:
DeleteObject[dir]channel = CreateChannel[]DeleteObject[channel]bin = CreateDatabin[]DeleteObject[bin]Create, cache and use a data resource object:
resource = ResourceObject[<|"ResourceType" -> "Data", "Name" -> "Divisors of 2^20", "Content" -> Divisors[2 ^ 20]|>]LocalCache[resource]ResourceData[resource]DeleteObject[resource]Retrieve a resource from the public data repository:
resource = ResourceObject["Fireballs and Bolides"]Remove the local cache of the resource:
DeleteObject[resource]session = StartExternalSession["Python"]DeleteObject[session]Start listening on an available socket, applying a handler function to events:
listener = SocketListen[Automatic, Print]DeleteObject[listener]Create and then remove a permissions group:
CreatePermissionsGroup["TigerTeam", {$CloudUserID, "user@wolfram.com"}]DeleteObject[PermissionsGroup["TigerTeam"]]Remove permissions keys from any cloud objects that are using them:
CloudDeploy[Delayed[RandomInteger[2 ^ 128]], Permissions -> PermissionsKey["altkey"] -> "Execute"]DeleteObject[PermissionsKey["altkey"]]job = RemoteBatchSubmit["WolframBatch", FactorInteger[2 ^ 1023 - 7]]DeleteObject[job]Use Once for a form of dynamic programming, using a custom location to cache the values computed:
fib[0] = 0;fib[1] = 1;
fib[n_] := Once[fib[n - 1] + fib[n - 2], "KernelSession" -> "fib"];Timing[Block[{$RecursionLimit = ∞}, res = fib[6000]];N[res]]Find the number of cached values generated:
Length[PersistentObjects[All, "KernelSession" -> "fib"]]Remove the cached values before redoing the timing experiment by deleting the custom persistence location:
DeleteObject[PersistenceLocation["KernelSession" -> "fib"]]Properties & Relations (3)
Symbols and local symbols are removed with Remove:
symbol = LocalSymbol["mysym"] = 0;Remove[symbol]Remove[LocalSymbol["mysym"]]Files are deleted with DeleteFile:
file = FileNameJoin[{CreateDirectory[], "test."}]Put[0, file]DeleteFile[file]In contrast to the default behavior of DeleteDirectory, DeleteObject deletes cloud directories even if they contain other objects:
CloudPut[42, CloudObject["mydir/myfile"]]DeleteDirectory[CloudObject["mydir"]]DeleteObject[CloudObject["mydir"]]DirectoryQ[CloudObject["mydir"]]See Also
DeleteFile DeleteDirectory Remove WithCleanup
Function Repository: ScheduleCloudObjectExpiration
Related Guides
Related Workflows
- Find All Initializations
Text
Wolfram Research (2017), DeleteObject, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteObject.html (updated 2025).
CMS
Wolfram Language. 2017. "DeleteObject." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/DeleteObject.html.
APA
Wolfram Language. (2017). DeleteObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeleteObject.html
BibTeX
@misc{reference.wolfram_2026_deleteobject, author="Wolfram Research", title="{DeleteObject}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/DeleteObject.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_deleteobject, organization={Wolfram Research}, title={DeleteObject}, year={2025}, url={https://reference.wolfram.com/language/ref/DeleteObject.html}, note=[Accessed: 12-June-2026]}