mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Added list-empty-files.ps1
This commit is contained in:
@ -13,8 +13,9 @@ try {
|
||||
$DirTree = read-host "Enter the path to the directory tree"
|
||||
}
|
||||
|
||||
write-progress "Checking symlinks in $DirTree..."
|
||||
[int]$SymlinksTotal = [int]$SymlinksBroken = 0
|
||||
gci $DirTree -Recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object {
|
||||
Get-ChildItem $DirTree -recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object {
|
||||
$Symlink = $_.FullName
|
||||
$Target = ($_ | Select-Object -ExpandProperty Target -ErrorAction Ignore)
|
||||
if ($Target) {
|
||||
|
22
Scripts/list-empty-files.ps1
Executable file
22
Scripts/list-empty-files.ps1
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./list-empty-files.ps1 [<dir-tree>]
|
||||
.DESCRIPTION lists empty files within the given directory tree
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
param($DirTree = "")
|
||||
|
||||
try {
|
||||
if ($DirTree -eq "" ) {
|
||||
$DirTree = read-host "Enter the path to the directory tree"
|
||||
}
|
||||
write-progress "Listing empty files in $DirTree ..."
|
||||
Get-ChildItem $DirTree -recurse | Where {$_.PSIsContainer -eq $false} | Where {$_.Length -eq 0} | select FullName
|
||||
echo "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Reference in New Issue
Block a user