Guest User

File Copier

a guest
Feb 28th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. @echo off
  2. setlocal ENABLEDELAYEDEXPANSION
  3. color 81
  4. mode con: cols=90 lines=45
  5.  
  6. echo ===============================Mass .RAR file copy utility================================
  7. echo ========This utility copies all files in the specified directory to its location.=========
  8.  
  9. pause
  10.  
  11. ::Map our P: drive to Q: on server
  12. :mapdrive
  13. echo Creating Mapped drive:
  14. net use /del Q:
  15. net use Q: \\SERVER\Temp <<Redacted, mapping works
  16. if not exist Q: echo Drive Map Failed, trying again.
  17. if not exist Q: pause
  18. if not exist Q: goto mapdrive
  19. if exist Q: echo Mapping successful!
  20.  
  21. ::Prompt for source folder on P: Drive
  22. :setsource
  23. set /P source=Enter path to files on P:(Temp) drive (EX: jdoe\copy)
  24.  
  25. ::Create a count of files in the source folder
  26. echo Counting source files, please wait.
  27. set count=0
  28. set total=0
  29. for %%s in (Q:%source%\*) do set /a total+=1
  30. echo %total% files will be copied.
  31. set sourceconfirm=y
  32. set sourceconfirm=Continue with this source? (Y/n)
  33. if /i sourceconfirm==n goto setsource
  34.  
  35. ::Offer to change destination
  36. set dest=D:Temp\Copy
  37. echo Default destination is D:Temp\Copy
  38. set destchange=N
  39. set /P destchange=Change destination? (y/N)
  40.  
  41. if /i %destchange%==N goto confirmdir
  42. if /i %destchange%==y goto setdir
  43.  
  44. :setdir
  45. set /P dest=Enter Destination (Exclude trailing \):
  46.  
  47. :confirmdir
  48. echo Destination directory is:
  49. echo %dest%
  50.  
  51. set confirm=y
  52. set /P confirm=Is this correct? (Y/n):
  53.  
  54. if /i %confirm%==n goto setdir
  55.  
  56. if exist %dest% echo Folder exists, continuing.
  57. if not exist %dest% mkdir %dest% & echo Folder created, continuing.
  58.  
  59. echo Copying will now begin.
  60. pause
  61. ::Copying files-
  62. ::For loop copies file, verifies file was copied,
  63. ::and removes file from source.
  64. for %%f in (Q:%source%\*) do (
  65. :recopy
  66. copy %%f %dest%\%%f
  67. if not exist %dest%\%%f goto recopy
  68. set /a count+=1
  69. del %source%\%%f
  70. echo copied !count! of %total%
  71. ping -n 1 -w 500 1.1.1.1 >nul
  72. )
  73. echo =======================Copying complete, continue to verification.========================
  74. pause
  75. ::Begin Verification
  76. set verify=0
  77.  
  78. for %%v in (%dest%\*) do set /a verify+=1
  79.  
  80. echo %total% files in source directory.
  81. echo %verify% files in destination directory.
  82.  
  83. if %total%==%verify% echo It appears that this utility was successful.
  84. if not %total%==%verify% color 47
  85. if not %total%==%verify% echo It appears there has been an error, check for missing files.
  86.  
  87. ::Un-Map drive
  88. net use /del Q:
  89. pause
  90. endlocal
Advertisement
Add Comment
Please, Sign In to add comment