On 11/15/2012 4:44 PM, Cathy wrote:
> I would like some assistance to write a simple batch file to check the
> file size of a specific file. The file is not allowed to be more than 5gb.
>
> The steps are therefore
>
> 1. Set Max_file_size = 5gb
> 2. Set warning_level = 10%
> 3. Set Warning_File_size = Max_file_size - (Max_file_size * warning_level)
> 3. Check file_size
> 4. if file_size > Warning_file_size
> Echo File is too large
> endif
>
> If anybody could help me get this scripted I would really appreciate it
Steps 1–3 always result in a warning file size of 4.5 GB. I've condensed
these steps; I leave it to the reader to expand them if desired.
I have not included any kind of error-checking. It is written as a
script, though you could instead make it a function.
param($File_Path)
$Warning_File_Size = 4.5GB
$File = Get-Item -Path $File_Path
if ($File.Length -gt $Warning_File_Size)
{
Write-Host "File is too large"
}
--
David Trimboli
http://www.trimboli.name/