Remove node_modules folder with powershell on windows

# USAGE ########################## # Copy-paste into new file rdel.ps1 # Run .\rdel.ps1 .\node_modules from powershell $path = $args[0] $chars = "abcdefghijklmnopqrstuvwxyz" function GetFileName($num) { $name = "" while($num -gt 25) { $name += "z" $num -= 26 } $name += $chars[$num] return $name } function RenameRec($xpath) { $counter = -1 $items = @(Get-ChildItem $xpath | ForEach-Object -Process {$_.FullName}) foreach($item in $items) { $counter += 1 $filename = split-path $item -Leaf $name = GetFileName($counter) #write-host "OLD $filename NEW $name" if($filename -ne $name){ #Write-Host "Renaming $item to $name" Rename-Item $item $name } } $folders = @(Get-ChildItem $xpath -Directory | ForEach-Object -Process {$_.FullName}) foreach($folder in $folders) { RenameRec($folder) } } Write-Host "Renaming all files... (this can take a while, Ignore any errors)" RenameRec($path) Remove-Item $path

2 Responses

You could just simply do `npm install rimraf` and then `rimraf nameofproject`.
Yes! I know :)

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.