This Windows PowerShell script takes an inventory of one folder and for each file that exists will execute a delete in another folder. I wrote this to deal with some bizarre node/gulp race conditions while doing image optimization. So if a file has been processed (compressed) it is ok to delete it from the images_in folder.
# 20160601 Scott C. Krause | |
# Remove files that exist within out from the in folder | |
# This Windows PowerShell script takes an inventory of one folder and for each file that exists will execute a delete in another folder. | |
# I wrote this to deal with some bizarre node/gulp race conditions while doing image optimization. | |
# So if a file has been processed (compressed) it is ok to delete it from the images_in folder. | |
$dest = "\\compressed" | |
$source = "\\images_product\images_in" | |
$in = Get-ChildItem $source | |
$out = Get-ChildItem $dest | |
Compare-Object -ReferenceObject $in -IncludeEqual $out -Property Name | Where-Object {$_.SideIndicator -eq "=="} | ForEach-Object { | |
Remove-Item "$($source)\$($_.name)" -Recurse | |
Write-Host "Removing $($source)\$($_.name)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
20160601 Scott C. Krause
Remove files that exist within out from the in folder
This Windows PowerShell script takes an inventory of one folder and for each file that exists will execute a delete in another folder.
I wrote this to deal with some bizarre node/gulp race conditions while doing image optimization.
So if a file has been processed (compressed) it is ok to delete it from the images_in folder.