Skip to content

Instantly share code, notes, and snippets.

@neodigm
Last active September 27, 2018 20:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/969dc69d44f5c1359e9094db09f291ed to your computer and use it in GitHub Desktop.
Save neodigm/969dc69d44f5c1359e9094db09f291ed to your computer and use it in GitHub Desktop.
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)"
}
@neodigm
Copy link
Author

neodigm commented Aug 22, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment