Batch file ใช้ (FOR) เพื่อตรวจสอบไฟล์ต่างๆว่า date modified ว่าตรงกับวันที่ปัจจุบันหรือไม่


File ที่ตรวจสอบ ชื่อไฟล์ test2.txt


@echo off
SET filename="test2.txt"

FOR %%f IN (%filename%) DO SET filedatetime=%%~tf
set testa = %filedatetime:~0,-9%
set testb = %date%
echo %filedatetime:~0,-6% >> 1.txt
echo %date:~4% >> 2.txt
set disa=
for /F "delims=" %%i in (1.txt) do set contenta=%%i
set disb=
 for /F "delims=" %%i in (2.txt) do set contentb=%%i
IF %contenta% == %contentb% (
       echo check file work  %contenta% %contentb%
    ) ELSE (
       echo check file fail %contenta% %contentb%
    )
break>1.txt
break>2.txt
pause:

แสดงความคิดเห็น

0 ความคิดเห็น