批处理文件以检查具有相同扩展名的文件 [英] Batch file to check file with the same extension
问题描述
所以我对代码不太好.
我有一个代码来检查扩展名为.txt
的文件的大小,我需要它来验证具有该扩展名的所有文件,并且如果大于"limit",则写一个(例如)size.txt
inside是超出大小限制的文件的名称.
我已经拥有并提供给我的代码是:(它没有写文件size.txt
的部分)
So im not so good with code.
I have a code that check the size of a file with the extension .txt
and i need it to verify all the file with that extention and, if is bigger than the "limit", write a (for example) size.txt
that inside is the name of the files that exceed the size limit.
The code that i already have, and was given to me is: (it dont have the part of write the file size.txt
)
@echo off
set file="C:\PSTCheck\*.ost"
set maxbytesize=3000
%1 %0 :: %file%
set len=%~z2
if %len% LSS %maxbytesize% (
exit
) ELSE (
msg * O ficheiro exedeu, diriga-se a Informatica
)
exit
如果这不是一种方法,请让我知道另一种编写代码的方法. 它需要在不同的Windows版本中运行
If it isnt a way to do it please let me know another way of making the code. It needs to run in different windows version
推荐答案
花了我一个小时,但这应该可以工作
took me an hour but this should work
@echo off
set maxsize=3000
cd [path to the folder where the files are]
del size.txt
cls
for %%F in (*.txt) do (
echo checking %%F
FOR %%I in (%%F) do if %%~zI GEQ %maxsize% echo %%F>>size.txt
)
echo done!
pause > NUL
这篇关于批处理文件以检查具有相同扩展名的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!