Script to delete Temp folders in a click
Posted: 19 Aug 2018 08:37
Well actually, a double-click, on a batch script found online, as shown below:
I have no problem understanding this script until we reached the third line.
As far as I know, rmdir means to remove empty directories. But what if the directory is not empty? Then the Temp folder won't be completely wiped out, since those directories won't be deleted.
I tested the script myself though, by creating a folder in %temp% and a text document inside the folder. I typed on cmd, magically enough, the folder is still gone, hence proving that the script works well to clean the whole folder. My guess is, that a text document is not equivalent to a file, hence the result.
But what is the truth behind this? Why is the folder still being deleted?
Code: Select all
cd C:\Users\USER\Appdata\Local\Temp
del * /s /q
rmdir /s /q "C:\Users\USER\Appdata\Local\Temp"
As far as I know, rmdir means to remove empty directories. But what if the directory is not empty? Then the Temp folder won't be completely wiped out, since those directories won't be deleted.
I tested the script myself though, by creating a folder in %temp% and a text document inside the folder. I typed
Code: Select all
rmdir /s /q "C:\Users\USER\Appdata\Local\Temp"
But what is the truth behind this? Why is the folder still being deleted?