It's sometimes necessary to check the size of a given file. For example, if you are to delete too big files on your hard drive or split single file into many parts. As usual, batch files are powerful enough to perform such task. The example below shows how to check batch file size (file is called 1.txt) and exit the script if the size is equal to 100 Kb.for %%a in (1.txt) do if %%~za EQU 102400 goto :EOF
You can use this example in scripts that you create with help of our award-winning program designed to write batch files.
You can use this example in scripts that you create with help of our award-winning program designed to write batch files.
hi,
ReplyDeletewould 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. i am new with batch file and trying hard to get this done.
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
hi,
ReplyDeleteAppreciate 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. 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
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
ReplyDeleteThanks 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
Hello!
ReplyDeleteProbably, you are looking for such kind of script:
@ECHO OFF
SET FILETYPE=*.avi
SET SIZELIMIT=102400
for /R %%I IN (%FILETYPE%) do (
if %%~zI GTR !SIZELIMIT! (
del ^< %SIZELIMIT%
echo sizelimit %%I
) ELSE (
echo.file not found
)
)
Hi i have a very long script in which i need some help to make certain modifications such as count the total characters used in the same batch file and some more.Would request to help me with your email ID so that i can share and get help on the script.
ReplyDeletemy email:ankit.kundu23@gmail.com
Thanks in Advance.