Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.5 KiB

  1. @REM normal cmd header stuff ...
  2. @echo off
  3. if defined _echo echo on
  4. if defined verbose echo on
  5. setlocal EnableDelayedExpansion EnableExtensions
  6. for /f %%a in ('echo %0') do set SCRIPT_NAME=%%~na
  7. set PULLSHARE=%1
  8. set PUSHSHARE=%2
  9. set LISTFILE=%3
  10. set EVENTNAME=%4
  11. set ExitCode=0
  12. call logmsg.cmd "Beginning %SCRIPT_NAME%..."
  13. time /t
  14. call logmsg.cmd "Pulling from %PULLSHARE% ..."
  15. call logmsg.cmd "Pushing to %PUSHSHARE% ..."
  16. if exist %PUSHSHARE% goto ContinueCopy1
  17. call errmsg.cmd "%PUSHSHARE% doesn't exist, exiting."
  18. goto Done
  19. :ContinueCopy1
  20. if exist %PULLSHARE% goto ContinueCopy2
  21. call errmsg.cmd "%PULLSHARE% doesn't exist, exiting."
  22. goto Done
  23. :ContinueCopy2
  24. REM Actually, do a full incremental xcopy once not stopping for errors, then
  25. REM once checking for errors. Note no error checking with the xcopy /c switch.
  26. for /f "tokens=3 delims=," %%a in (%LISTFILE%) do (
  27. for %%q in (%PUSHSHARE%\%%a) do set PathOnly=%%~pq
  28. xcopy /qcdhkr %PULLSHARE%\%%a \\!PathOnly! >nul
  29. REM don't error check now, do it below
  30. )
  31. time /t
  32. call logmsg.cmd "Making a second pass to error check ..."
  33. for /f "tokens=3 delims=," %%a in (%LISTFILE%) do (
  34. for %%q in (%PUSHSHARE%\%%a) do set PathOnly=%%~pq
  35. xcopy /dhkr %PULLSHARE%\%%a \\!PathOnly! >nul 2>nul
  36. if "!ErrorLevel!" neq "0" (
  37. call logmsg.cmd "copy failed for %%a, lets rename file on other side and retry"
  38. REM Rename file that can't be copied over by appending a .1 to .60 on the end of
  39. REM the file name. It is very unlikely that all these suffixes will be used up.
  40. set newnamesuffix=
  41. for /l %%b in (1, 1, 60) do (
  42. if not defined newnamesuffix (
  43. if NOT EXIST %PUSHSHARE%\%%a.%%b set newnamesuffix=%%b
  44. )
  45. )
  46. REM append suffix to file name
  47. set newname=%%a.!newnamesuffix!
  48. REM newname may have a path as a prefix, set newfilename to the filename.ext only
  49. for %%i in (!newname!) do (
  50. set newfilename=%%~nxi
  51. )
  52. call logmsg.cmd "will rename %PUSHSHARE%\%%a to !newfilename!"
  53. ren %PUSHSHARE%\%%a !newfilename!
  54. REM recopy new file
  55. xcopy /dhkr %PULLSHARE%\%%a \\!PathOnly! >nul 2>nul
  56. if "!ErrorLevel!" neq "0" (
  57. set ExitCode=1
  58. call errmsg.cmd "copy failed after retry: xcopy /dhkr %PULLSHARE%\%%a \\!PathOnly! "
  59. )
  60. )
  61. )
  62. :Done
  63. REM signal events
  64. perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl -h %EVENTNAME%
  65. perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl -s %EVENTNAME%
  66. :End
  67. endlocal
  68. goto :EOF