diff --git a/scripts/remove-dir-tree.ps1 b/scripts/remove-dir-tree.ps1 deleted file mode 100755 index a4fb4695..00000000 --- a/scripts/remove-dir-tree.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -<# -.SYNOPSIS - Removes a dir tree -.DESCRIPTION - This PowerShell script silently removes a directory tree recursively. Use it with care! -.PARAMETER pathToDirTree - Specifies the file path to the directory tree -.EXAMPLE - PS> ./remove-dir-tree.ps1 C:\Temp - ✅ Removed directory 'C:\Temp\ in 9s. -.LINK - https://github.com/fleschutz/PowerShell -.NOTES - Author: Markus Fleschutz | License: CC0 -#> - -param([string]$pathToDirTree = "") - -try { - if ($pathToDirTree -eq "" ) { $pathToDirTree = Read-Host "Enter the path to the directory tree" } - $stopWatch = [system.diagnostics.stopwatch]::startNew() - - Remove-Item -Force -Recurse -Confirm:$false $pathToDirTree - if ($lastExitCode -ne 0) { throw "'Remove-Item' failed with exit code $lastExitCode" } - - [int]$elapsed = $stopWatch.Elapsed.TotalSeconds - "✅ Removed directory '$pathToDirTree' in $($elapsed)s." - exit 0 # success -} catch { - "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" - exit 1 -} diff --git a/scripts/remove-dir.ps1 b/scripts/remove-dir.ps1 new file mode 100755 index 00000000..ffdf1a28 --- /dev/null +++ b/scripts/remove-dir.ps1 @@ -0,0 +1,35 @@ +<# +.SYNOPSIS + Removes a directory +.DESCRIPTION + This PowerShell script removes the given directory tree recursively. + NOTE: Use with care! This cannot be undone! +.PARAMETER pathToDir + Specifies the file path to the directory tree +.EXAMPLE + PS> ./remove-dir.ps1 C:\Temp + ⏳ Removing 'C:\Temp'... (please wait)" + ✅ Directory C:\Temp\ removed (took 9s). +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$pathToDir = "") + +try { + if ($pathToDir -eq "" ) { $pathToDir = Read-Host "Enter the file path to the obsolete directory" } + $stopWatch = [system.diagnostics.stopwatch]::startNew() + "⏳ Removing '$pathToDir'... (please wait)" + + Remove-Item -Force -Recurse -Confirm:$false $pathToDir + if ($lastExitCode -ne 0) { throw "'Remove-Item' failed with exit code $lastExitCode" } + + [int]$elapsed = $stopWatch.Elapsed.TotalSeconds + "✅ Directory $pathToDir removed (took $($elapsed)s)." + exit 0 # success +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}