How to delete a large folder that contains millions of files 

Problems

The Jenkins workspace contains a large folder that consumes disk space of about 70%. It is hard to delete via GUI, It takes about 10 hours to delete , because its contains millions of files (test result / build log etc)

Solution

Folder Structure

D:
|--JENKIN_AGENTS
   |--NET_CODE
      |--338555_repoEOD2Tmp    << I Want to delete this folder
      |--402899_DigtalAssetEOD
  • Open Terminal, Navigate to D:\NET_CODE\ (For scope)
cd "D:\JENKIN_AGENTS\NET_CODE\"
  • Delete folder 338555_repoEOD2Tmp via Powershell Command
#Template 
Remove-Item -LiteralPath 'Your_Folder' -Force -Recurse

# Delete Folder 338555_repoEOD2Tmp
Remove-Item -LiteralPath '338555_repoEOD2Tmp' -Force -Recurse
  • Wait For 5-10 minutes

Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.