[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 52
  • Last Modified:

Find and delete zero filesize file with SCOM

Hi Experts,

I would like to find and delete zero filesize file in a particular folder with SCOM management pack.
Could you please advise the best way of achieving this?
0
jianny
Asked:
jianny
2 Solutions
 
vivigattCommented:
SCOM is not required. You can use this batch file :

@echo off

setlocal enabledelayedexpansion

set "SEARCH_DIR=%~1"
set FILE_SIZE=0

if not exist "%SEARCH_DIR%" (
    echo Usage: %~nx0 directory 
    echo Lists all files in given directory and its subdirectories that have a zero size
    echo.
    echo "%SEARCH_DIR%" does not exist.
    exit /b 1
)

for /R "%SEARCH_DIR%" %%F in (*) do (
    if exist "%%F" if %%~zF EQU %FILE_SIZE% echo %%F
)

Open in new window

0
 
Mike TLeading EngineerCommented:
*cough* powershell. Message ends.
0
 
serialbandCommented:
Get-Childitem "PathToFiles" | where {$_.length -eq 0} | remove-Item

Get-Childitem -Recurse | % {
  if(!$_.PSIsContainer -and $_.length -eq 0) {
    write-host ("{0}: {1}" -f $_.FullName, $_.length) | remove-item
   }
}
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now