I have a drive with many thousands of sound effects. The files have been stored on different operating systems and NAS devices over time and there are now duplicates of many files, but the filenames contain different UTC timestamps. For example:
1-14 Crowded Bowling Alley (2016_06_28 02_14_41 UTC).aif
1-14 Crowded Bowling Alley (2016_02_18 05_56_59 UTC).aif
I would like to remove the duplicate files. There are also junk files left over from audio software and operating system indexing that I would like to remove. Using a copied subset of the data I have tested the following PowerShell script under PS version 5.1, it appears to give me what I'm after:
# Remove files left over from audio editors
Get-ChildItem -Name -Recurse -Filter "*.clip*" | Remove-Item
Get-ChildItem -Name -Recurse -Filter "*.ptf" | Remove-Item
Get-ChildItem -Name -Recurse -Filter "*.wfm" | Remove-Item
Get-ChildItem -Name -Recurse -Filter "*.repeaks" | Remove-Item
# Remove old indexing files
Get-ChildItem -Name -Recurse -Filter "*.DS_STORE" | Remove-Item
Get-ChildItem -Name -Recurse -Filter "._.*" | Remove-Item
Get-ChildItem -Name -Recurse -Filter "Thumbs*.db" | Remove-Item
Get-ChildItem -Name -Recurse -Filter "*.ini" | Remove-Item
# Remove UTC stamp from all files (will fail on duplicates)
Get-ChildItem -Recurse -Filter "*(?????????? ???????? UTC).*" | Rename-Item -newname { $_.basename.substring(0,$_.basename.length-26) + $_.Extension }
# Remove files that still have the UTC stamp (they were the duplicates)
Get-ChildItem -Name -Recurse -Filter "*(?????????? ???????? UTC).*" | Remove-Item
However, I would love to get a critique of the script and learn a few things. In particular it seems a little hacky to use an expected failed command as part of the workflow. It also seemed wise to get notes before I run it on the entire set of files.