I am trying to compare the current timestamp with the changed timestamp of a file..
I would use something like that for the current timestamp:
set d=%date:~6,4%-%date:~3,2%-%date:~0,2%
set t=%time::=.%
set t=%t: =0%
set currentstamp="%d% %t%"
I would use something like that for the modified timestamp:
set filetimestamp=dir /T:W C:\test.txt
And then I would compare these variables:
if filetimestamp>currentstamp (...)
EDIT: My current version looks like this. There is a mistake, but I can't find him.
set NEWDIRECTORY=D:\test
set PROJECTNAMES=(projekt1)
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set TIMESTAMP2=%%I
set TIMESTAMP2=%TIMESTAMP2:~0,8%-%TIMESTAMP2:~8,6%
rem do some things
for %%A in %PROJECTNAMES% do (
for %%F in (C:\%%A.exe) do set file=%%~fF
for /f "tokens=2 delims==" %%I in ('wmic datafile where name^="%file:\=\\%" get lastmodified /format:list') do set TIMESTAMP1=%%I
if %TIMESTAMP1% lss %TIMESTAMP2% (XCOPY "C:\%%A.exe" "%NEWDIRECTORY%\%%A.exe" /Y)
)