Created
July 6, 2020 00:55
-
-
Save gpoole/4c60b683617141c8742b13f6d7c341fa to your computer and use it in GitHub Desktop.
Delete image files that don't have any name references in source files
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
function FindAny() { | |
param($name) | |
$found = Get-ChildItem . -Recurse -Include *.js, *.css, *.html, *.xml | | |
? { $_.FullName -notmatch "node_modules" -and $_.FullName -notmatch "bower_components" } | | |
Select-String $name | |
return ($found | Measure-Object -Line).Lines -gt 0; | |
} | |
Get-ChildItem "web\images" | ? { -Not (FindAny $_.Name) } | rm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment