I used it for removing duplicates from my music library.
It is simply listing all the duplicates files from a directory and copy them to a back up folder.
$musicFolder = "c:\MyFolder" $backupFolder = "c:\Backup" echo "Get duplicates" $dupmusics = ls $musicFolder -recurse | Group-Object Length, LastWriteTime | Where { $_.Count -gt 1 } if($dupmusics.Length -gt 0) { echo "Move duplicates" $dupmusics = $dupmusics | ForEach-Object { $_.Group[1..$_.Group.Count] } | Move-Item -Destination $backupFolder -Verbose } else { echo "no duplicates found" }
Thank you for this comment.
ReplyDelete