mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-16 09:50:02 +01:00
Update list-hidden-files.ps1
This commit is contained in:
parent
7ba6813c67
commit
3a5aa8a8cc
@ -1,30 +1,35 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Lists hidden files in a directory tree
|
||||
Lists all hidden files in a directory tree
|
||||
.DESCRIPTION
|
||||
This PowerShell script scans and lists all hidden files in a directory tree.
|
||||
.PARAMETER DirTree
|
||||
Specifies the path to the directory tree
|
||||
This PowerShell script scans a directory tree and lists all hidden files.
|
||||
.PARAMETER path
|
||||
Specifies the path to the directory tree (default is current working dir)
|
||||
.EXAMPLE
|
||||
PS> ./list-hidden-files.ps1 C:\
|
||||
PS> ./list-hidden-files.ps1 C:\Windows
|
||||
...
|
||||
✔️ Found 256 hidden files within 📂C:\Windows in 40 sec
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$DirTree = "$PWD")
|
||||
param([string]$path = "$PWD")
|
||||
|
||||
try {
|
||||
$DirTree = resolve-path "$DirTree"
|
||||
write-progress "Listing hidden files in $DirTree ..."
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
[int]$Count = 0
|
||||
get-childItem "$DirTree" -attributes Hidden -recurse | foreach-object {
|
||||
$path = Resolve-Path "$path"
|
||||
Write-Progress "Scanning $path for hidden files..."
|
||||
[int]$count = 0
|
||||
Get-ChildItem "$path" -attributes Hidden -recurse | Foreach-Object {
|
||||
"📄 $($_.FullName)"
|
||||
$Count++
|
||||
$count++
|
||||
}
|
||||
"✔️ directory tree $DirTree has $Count hidden file(s)"
|
||||
Write-Progress -completed " "
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Found $count hidden files within 📂$path in $elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user