Checking file size in NT (batch)

n/a
August 2, 2007 at 05:26:20
Specs: NT 4, n/a
In XP this works
"if %~z1 GTR 1000 ..."
But this doesn't work i NT. Does anyone have any idea how to get it to work in NT?


See More: Checking file size in NT (batch)

Report •


#1
August 2, 2007 at 05:48:18
Actually, it wouldn't work in XP. You forgot the /I.

Report •

#2
August 2, 2007 at 06:50:33
#1,

I dunno /L bit this works in NT5:
=======================
@echo off
setLocal EnableDelayedExpansion
echo %~z1
if %~z1 GTR 10 echo biggger
========================


=====================================
If at first you don't succeed, you're about average.

M2



Report •

#3
August 3, 2007 at 00:37:35
Thanks! But it wont work in NT 4. This is returned:

Invalid parameter to SETLOCAL command
The following usage of the path operator in batch-parameter
substitution is invalid: %~z1


For valid formats type CALL /? or FOR /?


Report •

Related Solutions

#4
August 3, 2007 at 02:07:20
=======================
@echo off
setLocal
echo %~z1
if %~z1 GTR 10 echo biggger
========================



=====================================
If at first you don't succeed, you're about average.

M2



Report •

#5
August 3, 2007 at 02:35:20
Thanks again :)

That returned:

The following usage of the path operator in batch-parameter
substitution is invalid: %~z1


Report •

#6
August 3, 2007 at 02:41:57
I'm not running NT4. I guess that ~Z won't fly

You may need to use DIR and chop out the size. Before you go to the trouble, check and see if GTR works.


=====================================
If at first you don't succeed, you're about average.

M2



Report •

#7
August 29, 2007 at 14:22:17
I guess it wasn't urgent.


=====================================
If at first you don't succeed, you're about average.

M2



Report •

#8
July 30, 2011 at 13:35:54
hi,

would Appreciate if you help me with below motioned script actually I am trying to write a batch file which can search *.avi and check if it is more than 200 MB restrict the file by using cacls or del the same. i m new with batch file and trying hard to get this done please help me

Thanks in advance.


@ECHO OFF
SET FILETYPE=*.mp3
SET SIZELIMIT=7,425,794
for /R d:\ %I IN ('%FILETYPE%') do set FILESIZE=%~xI

if %FILESIZE% GTR %SIZELIMIT% (
del %SIZELIMIT%
) ELSE (
echo.file not found
)

Shad


Report •


Ask Question