You can get information about the date and time the file was changed in the script package, but you need to remember the following things:
- It is a combination of date and time;
- it is locale specific;
- this is a string.
This means that before the comparison, you will need to disable the temporary part, for which you will need to take into account the display format, as indicated in the regional settings of the system. And since this is a string, you can probably only check if it is a specific date, but whether it refers to a specific period.
And here is how you can implement this:
SET filename="C:\Documents and Settings\%username%\Application Data\Microsoft\Outlook\test.OTM" IF NOT EXIST %filename% GOTO log FOR %%f IN (%filename%) DO SET filedatetime=%%~tf IF "%filedatetime:~0,-6%" == "%checkdate%" GOTO END :log ECHO %DATE%_%TIME%_%COMPUTERNAME% >> %LOG1%
On my system, %%~tf will return the date and time formatted as dd.MM.yyyy hh:mm . Thus, the %filedatetime:~0,-6% follows this format and accordingly reduces the time part. You may need to slightly modify the expression to suit your case.
The last thing is a predefined variable called USERPROFILE . It points to the active user folder, C:\Documents and Settings\ username . Thus, you can reduce the path string to this: "%USERPROFILE%\Application Data\Microsoft\Outlook\test.OTM" .
source share