Powershell | Determine file size

$myfile = "c:\test.zip"
$minsize = "100" # minimum file size is set to 100kb

if(Test-Path $myfile) # if my file exists
{

$myfilesize=Get-ChildItem $myfile | Select-Object @{Name="Kbytes";Expression={$_.Length / 1Kb}}

#clean unnecessary data
$myfilesize=[regex]::replace($myfilesize, "@{Kbytes=", "")
$myfilesize=[regex]::replace($myfilesize, ".[\d]*}", "")

if($myfilesize -ge $minsize)
{
#TODO: file is greater or equal than 100kb, do something
}

}

Comments

Popular posts from this blog

Mobile development opportunities

Breaking down document locking in SharePoint

Working around X-Frame-Options for iframes