I'm trying to delete a large directory. I run the delete (del /f node_modules), and it appears to work, but then the directory is still there… (When I try to delete it from the file explorer, it usually gives me some flavor of "you need admin permissions" or "can't delete because file is in use" or it just takes forever.)
Here's my question: what causes the del command to appear to work, but not actually work? I'd expect some output indicating the directory wasn't deleted.
Best Answer
If I didn't have appropriate permissions, the cmd doesn't throw an access denied or something?
That's not how
del
is designed to work. If files are deleted, thendel
will inform you. If no files are deleted thendel
is silent or will display an error message (for example "Access is denied.").Source Del - Delete Files - Windows CMD - SS64.com
If no files are deleted and you do not have the appropriate permissions to remove them an error message will be displayed:
I'd expect some output indicating the directory wasn't deleted.
If you use
del
with a directory name then it will delete the files in the directory. The directory specified is not deleted.Source Del - Delete Files - Windows CMD - SS64.com
To delete both directories and the files and subdirectories use
rd
(an alias forrmdir
):Source - RD - Remove Directory - Windows CMD - SS64.com