Advertisement
rodrigosantosbr

Cmd to clear temp files

Mar 31st, 2020 (edited)
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :: This script deletes all contents of a folder.
  2. :: This version also does not delete the root folder itself.
  3. @ECHO OFF
  4.  
  5. SET FOLDER=C:\Users\Administrator\syncState
  6. if [%FOLDER%]==[] EXIT
  7.  
  8. :: Delete all files in a folder
  9. DEL /F/Q/S "%FOLDER%" > NUL
  10.  
  11. :: Delete all subfolders
  12. :: repeat because RD is sometimes buggy
  13. :: Newer versions of Windows do not have DELTREE command
  14. For /d %%G in (%FOLDER%\*) do RD /s /q "%%G"
  15.  
  16. SET FOLDER2=C:\Users\Administrator\AppData\Local\Temp
  17. if [%FOLDER2%]==[] EXIT
  18.  
  19. :: Delete all files starting with report in a folder
  20. DEL /F/Q/S "%FOLDER2%\report*" > NUL
  21.  
  22. EXIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement