Last active
September 27, 2018 20:00
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
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.