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.

93 lines
1.5 KiB

  1. @setlocal
  2. @echo off
  3. rem %1 is the source path
  4. rem %2 is the target path
  5. rem %3 is the file name
  6. rem %logfile% is the output log
  7. set session=%random%
  8. :sourcecheck
  9. if exist %1\%3 goto targetcheck
  10. echo %~n0: source file %1\%3 does not exist >> %logfile%
  11. goto leave
  12. :targetcheck
  13. mkdir %2 2>nul
  14. del %2\*.deleted 2>nul
  15. :unique
  16. set tempname=propfile.%session%.%random%
  17. if exist %2\%tempname% goto unique
  18. echo copy %1\%3 %2\%tempname% >> %logfile%
  19. copy %1\%3 %2\%tempname% >> %logfile%
  20. if exist %2\%tempname% goto created
  21. echo %~n0: copy %1\%3 to %2\%tempname% failed >> %logfile%
  22. goto leave
  23. :created
  24. if not exist %2\%3 goto swapin
  25. echo del %2\%3 >> %logfile%
  26. del %2\%3 >> %logfile%
  27. if not exist %2\%3 goto swapin
  28. :again
  29. set deleted=%3.%session%.%random%.deleted
  30. if exist %2\%deleted% goto again
  31. echo ren %2\%3 %deleted% >> %logfile%
  32. ren %2\%3 %deleted% >> %logfile%
  33. if not exist %2\%3 goto swapin
  34. echo %~n0: can't delete or move existing %2\%3 >> %logfile%
  35. goto nukecopy
  36. :swapin
  37. echo ren %2\%tempname% %3 >> %logfile%
  38. ren %2\%tempname% %3 >> %logfile%
  39. if exist %2\%3 goto leave
  40. echo %~n0: unable to rename %2\%tempname% %3 >> %logfile%
  41. goto nukecopy
  42. :nukecopy
  43. echo del %2\%tempname% >> %logfile%
  44. del %2\%tempname% >> %logfile%
  45. goto leave
  46. :leave
  47. endlocal