Getting notification from xcopy if file copy

Viewed 959

I am generating a Windows Batch script to copy a file, only when the source is updated. If the file is updated, I want to delete another file.

The problem is that I can't find a simple way to trigger an event when the file update happens.

I thought of using %ERRORLEVEL% but this gives 0 whether file is copied or not.

I also thought of saving the xcopy output to a text file and then processing the file but this just seems to a little impractical for such a simple task?

Any other Ideas?

Code so far

SET SOURCEFILE=%CD%\source.txt
SET DELFILE=%CD%\toDelete.txt
SET DESTDIR=%WINDIR%\Deployment\ 

xcopy "%SOURCEFILE%" "%DESTDIR%" /c /d /q /y

REM IF File is updated, delete %DELFILE%
1 Answers
Related