Skip to content

Instantly share code, notes, and snippets.

@RobsonAutomator
Last active November 27, 2016 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobsonAutomator/0aaebebdb4837b1a1419ac4e7ebf70ef to your computer and use it in GitHub Desktop.
Save RobsonAutomator/0aaebebdb4837b1a1419ac4e7ebf70ef to your computer and use it in GitHub Desktop.
Remove media items where size is set to 0
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