hctcopy.cmd 836 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. @echo off
  2. setlocal
  3. if "%~3"=="" goto :usage
  4. if not exist "%~1\." (
  5. echo error: No source directory %1
  6. exit /b 1
  7. )
  8. :collect_files
  9. if "%~3"=="" goto :done
  10. if not exist "%~1\%~3" (
  11. echo error: source file does not exist: "%~1\%~3"
  12. exit /b 1
  13. )
  14. set FILES=%FILES% "%~3"
  15. shift /3
  16. goto :collect_files
  17. :done
  18. if not exist "%~2\." mkdir %2
  19. robocopy /NP /NJH /NJS %1 %2 %FILES%
  20. if errorlevel 8 (
  21. exit /b %errorlevel%
  22. )
  23. exit /b 0
  24. :usage
  25. echo Usage:
  26. echo hctcopy sourcedir destdir file1 [file2 [file3 ...]]
  27. echo where file# may be wildcard pattern
  28. echo.
  29. echo Uses robocopy plus extra features:
  30. echo /NP (no percent progress) /NJH (no job header) /NJS (no job summary)
  31. echo Verify existence of source directory
  32. echo Verify existence of each file pattern in source directory
  33. echo Create dest directory if it doesn't exist
  34. exit /b 1