@echo off setlocal EnableDelayedExpansion
del 1.txt /q
del 2.txt /q
for %%i in (*) do (echo %%~fzi >>1.txt) rem 將文件大小存儲(chǔ)到1.txt
for /f "tokens=1* delims= " %%a in (1.txt) do (
set "zer=%%a"
set "pat=%%b"
if !zer! gtr 5120 (
if not "!pat:~0,-1!"=="%~0" echo "!pat:~0,-1!" echo "!pat!" >> 2.txt rem 將大于5KB的文件名稱放到2.txt中
)
)
echo "done."
1、if exist d:\test.txt (echo D盤(pán)下有test.txt存在) else (echo D盤(pán)下不存在test.txt)
2、if "abc"=="xyz" (echo 字符串a(chǎn)bc等于字符串xyz) else (echo 字符串a(chǎn)bc不等于字符串xyz)
3、if 1 equ 2 (echo 1等于2) else (echo 1不等于2)
4、if defined str (echo 變量str已經(jīng)被賦值,其值為%str%) else (echo 變量str的值為空)