Added list-empty-files.ps1

This commit is contained in:
Markus Fleschutz 2021-02-10 18:37:55 +01:00
parent cf7b28a93f
commit 61b0c3e65d
4 changed files with 26 additions and 1 deletions

View File

@ -30,6 +30,7 @@ list-current-timezone.ps1, lists the current time zone details
list-clipboard.ps1, lists the contents of the clipboard
list-environment-variables.ps1, lists all environment variables
list-empty-dirs.ps1, lists empty subfolders within the given directory tree
list-empty-files.ps1, lists empty files within the given directory tree
list-files.ps1, lists all files in the given folder and also in every subfolder
list-formatted.ps1, lists the current working directory formatted in columns
list-fritzbox-calls.ps1, lists the FRITZ!Box calls

1 Filename Description
30 list-clipboard.ps1 lists the contents of the clipboard
31 list-environment-variables.ps1 lists all environment variables
32 list-empty-dirs.ps1 lists empty subfolders within the given directory tree
33 list-empty-files.ps1 lists empty files within the given directory tree
34 list-files.ps1 lists all files in the given folder and also in every subfolder
35 list-formatted.ps1 lists the current working directory formatted in columns
36 list-fritzbox-calls.ps1 lists the FRITZ!Box calls

View File

@ -36,6 +36,7 @@ Table of Contents
* [list-current-timezone.ps1](Scripts/list-current-timezone.ps1) - lists the current time zone details
* [list-environment-variables.ps1](Scripts/list-environment-variables.ps1) - lists all environment variables
* [list-empty-dirs.ps1](Scripts/list-empty-dirs.ps1) - lists empty subfolders within the given directory tree
* [list-empty-files.ps1](Scripts/list-empty-files.ps1) - lists empty files within the given directory tree
* [list-installed-software.ps1](Scripts/list-installed-software.ps1) - lists the installed software
* [list-files.ps1](Scripts/list-files.ps1) - lists all files in the given folder and also in every subfolder
* [list-formatted.ps1](Scripts/list-formatted.ps1) - lists the current working directory formatted in columns

View File

@ -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
View 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
}