Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [CmdLetBinding()]
- Param(
- )
- Add-Type -AssemblyName Microsoft.VisualBasic
- function Remove-Item-ToRecycleBin($Path) {
- $item = Get-Item -Path $Path -ErrorAction SilentlyContinue
- if ($item -eq $null)
- {
- Write-Error("'{0}' not found" -f $Path)
- }
- else
- {
- $fullpath=$item.FullName
- Write-Verbose ("Moving '{0}' to the Recycle Bin" -f $fullpath)
- if (Test-Path -Path $fullpath -PathType Container)
- {
- [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory($fullpath,'OnlyErrorDialogs','SendToRecycleBin')
- }
- else
- {
- [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($fullpath,'OnlyErrorDialogs','SendToRecycleBin')
- }
- }
- }
- $status = git status -s | ? { $_.StartsWith("??")}
- $status | % {
- $file = $_.Replace("?? ", ".\").Replace("/","\")
- if(Test-Path($file)){
- Write-Warning "$file"
- }
- }
- $confirm = Read-Host -Prompt "Are you sure you want to remove all the untracked files and folders?? [Yes] to confirm"
- if($confirm -ne "Yes"){
- Write-Host "No files is deleted"
- return;
- exit;
- }
- $status | % {
- $file = $_.Replace("?? ", ".\").Replace("/","\")
- if(Test-Path($file)){
- Remove-Item-ToRecycleBin((ls $file).FullName)
- }
- }
Add Comment
Please, Sign In to add comment