fix formatting and messaging
This commit is contained in:
@ -189,7 +189,6 @@ function Get-Duplicates {
|
|||||||
|
|
||||||
if ($dup_files.Count -gt 1) {
|
if ($dup_files.Count -gt 1) {
|
||||||
$dups_hash[$entry.key] = $dup_files | Sort-Object -Property Creation -Descending
|
$dups_hash[$entry.key] = $dup_files | Sort-Object -Property Creation -Descending
|
||||||
#$dup_files = $dups_hash[$entry.key]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dups_hash
|
$dups_hash
|
||||||
@ -214,14 +213,18 @@ function Show-Duplicates {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
Write-Output "Found duplicate $($num_dups): $($entry.Key)"
|
Write-Output "Found duplicate $(Format-NumberWithCommas $num_dups): $($entry.Key)"
|
||||||
|
|
||||||
for ($i = 0; $i -lt $dup_files.Count; $i++) {
|
for ($i = 0; $i -lt $dup_files.Count; $i++) {
|
||||||
$total_dup_size += $dup_files[$i].Size
|
# only count disk space of removals
|
||||||
|
if ($i -gt 0) {
|
||||||
|
$total_dup_size += $dup_files[$i].Size
|
||||||
|
}
|
||||||
Write-Output "$($hash_num): $($dup_files[$i].ToString())"
|
Write-Output "$($hash_num): $($dup_files[$i].ToString())"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
Write-Output "Found $num_dups duplicate file hashes."
|
Write-Output "Found $(Format-NumberWithCommas $num_dups) duplicate file hashes."
|
||||||
ShowSizes "Duplicate Files Size" $total_dup_size
|
ShowSizes "Duplicate Files Size" $total_dup_size
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +285,7 @@ function DeleteDuplicateFile {
|
|||||||
Write-Output "Deleting File: $($File.Name) $(Format-NumberWithCommas $File.fileSizeInKB) KB"
|
Write-Output "Deleting File: $($File.Name) $(Format-NumberWithCommas $File.fileSizeInKB) KB"
|
||||||
BackupDuplicateFile -file $File -backupDirectory $backup_dir
|
BackupDuplicateFile -file $File -backupDirectory $backup_dir
|
||||||
# Force delete a read-only or protected file
|
# Force delete a read-only or protected file
|
||||||
Write-Output " ... would deleting: $($File.FullName)"
|
Write-Output " ... deleting: $($File.FullName)"
|
||||||
Remove-Item -Path $File.FullName -Force
|
Remove-Item -Path $File.FullName -Force
|
||||||
Write-Output " - removed from: $($File.Directory)"
|
Write-Output " - removed from: $($File.Directory)"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user