mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-21 01:18:18 +02:00
Improved the scripts
This commit is contained in:
parent
61b0c3e65d
commit
47459e0139
@ -28,7 +28,7 @@ try {
|
|||||||
}
|
}
|
||||||
$SymlinksTotal++
|
$SymlinksTotal++
|
||||||
}
|
}
|
||||||
write-output "Done - found $SymlinksTotal symlinks total, $SymlinksBroken are broken"
|
write-host -foregroundColor green "Done - $SymlinksBroken out of $SymlinksTotal are broken"
|
||||||
exit $SymlinksBroken
|
exit $SymlinksBroken
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -12,9 +12,13 @@ try {
|
|||||||
if ($DirTree -eq "" ) {
|
if ($DirTree -eq "" ) {
|
||||||
$DirTree = read-host "Enter the path to the directory tree"
|
$DirTree = read-host "Enter the path to the directory tree"
|
||||||
}
|
}
|
||||||
write-progress "Listing empty subfolders in $DirTree ..."
|
write-progress "Listing empty directories in $DirTree..."
|
||||||
(Get-ChildItem $DirTree -recurse | ? {$_.PSIsContainer -eq $True}) | ?{$_.GetFileSystemInfos().Count -eq 0} | select FullName
|
[int]$Count = 0
|
||||||
echo "Done."
|
Get-ChildItem $DirTree -recurse | Where {$_.PSIsContainer -eq $true} | Where {$_.GetFileSystemInfos().Count -eq 0} | ForEach-Object {
|
||||||
|
write-output $_.FullName
|
||||||
|
$Count++
|
||||||
|
}
|
||||||
|
write-host -foregroundColor green "Done - found $Count empty directories"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -13,8 +13,12 @@ try {
|
|||||||
$DirTree = read-host "Enter the path to the directory tree"
|
$DirTree = read-host "Enter the path to the directory tree"
|
||||||
}
|
}
|
||||||
write-progress "Listing empty files in $DirTree ..."
|
write-progress "Listing empty files in $DirTree ..."
|
||||||
Get-ChildItem $DirTree -recurse | Where {$_.PSIsContainer -eq $false} | Where {$_.Length -eq 0} | select FullName
|
[int]$Count = 0
|
||||||
echo "Done."
|
Get-ChildItem $DirTree -recurse | Where {$_.PSIsContainer -eq $false} | Where {$_.Length -eq 0} | ForEach-Object {
|
||||||
|
write-output $_.FullName
|
||||||
|
$Count++
|
||||||
|
}
|
||||||
|
write-host -foregroundColor green "Done - found $Count empty files"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user