Last active
November 27, 2016 12:41
-
-
Save RobsonAutomator/0aaebebdb4837b1a1419ac4e7ebf70ef to your computer and use it in GitHub Desktop.
Remove media items where size is set to 0
This file contains 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
cd 'master:/sitecore/media library' | |
function AddPathMember($item) | |
{ | |
$path = $item.Paths.Path; | |
$item | Add-Member -MemberType NoteProperty -Name Path -Value $path; | |
return $item | |
} | |
Get-ChildItem -Recurse . | Where-Object { $_.Size -eq 0 } | | |
ForEach-Object { return AddPathMember($_) } | | |
ForEach-Object { Remove-Item -Path $_.Path -WhatIf; return $_} | | |
Show-ListView -Property Name, Size, Path, 'File Path' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment