Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem --compares the age of two files
- rem --by Vasil "npocmaka" Arnaudov
- call :isOlder "C:\test.file1" "C:\test.file2"
- goto :eof
- :isOlder [%1 path to first file ; %2 path to second file]
- setlocal
- call :get_file_c_time "%~1" time1
- call :get_file_c_time "%~2" time2
- if "%time1%" LEQ "%time2%" (
- echo YES
- ) else (
- echo NO
- )
- goto :eof
- :get_file_c_time [ %1 path to file; %2 variable to assign value ]
- set file_path=%~1
- if not exist "%file_path%" echo file %1 does not exist&& exit /b 1
- if "%~2" equ "" echo need a secont parameter && exit /b 2
- setlocal enableDelayedExpansion
- for /f "skip=5 tokens=1,2,3,4,5,6 delims=/:.гчЈз " %%T in ('dir /tc "%file_path%"') do (
- if "%%Y" EQU "PM" (
- set /a "hour=%%W+12"
- ) else (
- set hour=%%W
- )
- set ftime=%%V%%U%%T!hour!%%Y
- goto :endfor
- )
- :endfor
- endlocal & set "%~2=%ftime%"
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement