automatically delete files that exist in another folder

Instead of removing items from one Google Photos gallery I decided to add them to another folder – dang, a 190 picture selection lost.

As I needed to download the images anyway, I got the idea: just download both albums and throw in a little PowerShell – to “re-do” the removal of the unwanted images for me!

$filesToRemove = (gci .\folderB\).Name
gci .\folderA\ | % { if ($filesToRemove -contains $_) { Remove-Item $_.FullName } else { echo “nope” }}

And done!
Writing this picece of PowerShell plus this blogpost took less than 5 minutes – about half the time it’d need me to re-select and remove the images manually – thanks PowerShell!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.