- #########################
- ##### Configuration
- #########################
- $Target_Directory = "C:\Folder\"
- $Max_Lines = 2
- #########################
- ##### Main
- #########################
- Clear-Host
- Write-Host "=== Start" -BackgroundColor Black
- $Total_Files = 0
- $Deleted_Files = 0
- $Skipped_Files = 0
- Get-ChildItem $Target_Directory -Filter *.* |
- Foreach-Object {
- $Total_Files++
- $Current_Lines = 0;
- if ($Current_Lines -gt $Max_Lines) {
- Write-Host "$($_.FullName) has $Current_Lines/$Max_Lines lines: deleting..." -BackgroundColor Red
- $Deleted_Files++
- } else {
- Write-Host "$($_.FullName) has $Current_Lines/$Max_Lines lines: skipping..." -BackgroundColor Green
- $Skipped_Files++
- }
- }
- Write-Host "===== Results" -BackgroundColor Black
- Write-Host "Total Files: $Total_Files | Deleted Files: " -NoNewLine -BackgroundColor Black
- Write-Host "$Deleted_Files" -ForegroundColor Red -NoNewline -BackgroundColor Black
- Write-Host " | Skipped Files: " -NoNewLine -BackgroundColor Black
- Write-Host "$Skipped_Files " -ForegroundColor Green -BackgroundColor Black
Последни пейстове