Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal ENABLEDELAYEDEXPANSION
- color 81
- mode con: cols=90 lines=45
- echo ===============================Mass .RAR file copy utility================================
- echo ========This utility copies all files in the specified directory to its location.=========
- pause
- ::Map our P: drive to Q: on server
- :mapdrive
- echo Creating Mapped drive:
- net use /del Q:
- net use Q: \\SERVER\Temp <<Redacted, mapping works
- if not exist Q: echo Drive Map Failed, trying again.
- if not exist Q: pause
- if not exist Q: goto mapdrive
- if exist Q: echo Mapping successful!
- ::Prompt for source folder on P: Drive
- :setsource
- set /P source=Enter path to files on P:(Temp) drive (EX: jdoe\copy)
- ::Create a count of files in the source folder
- echo Counting source files, please wait.
- set count=0
- set total=0
- for %%s in (Q:%source%\*) do set /a total+=1
- echo %total% files will be copied.
- set sourceconfirm=y
- set sourceconfirm=Continue with this source? (Y/n)
- if /i sourceconfirm==n goto setsource
- ::Offer to change destination
- set dest=D:Temp\Copy
- echo Default destination is D:Temp\Copy
- set destchange=N
- set /P destchange=Change destination? (y/N)
- if /i %destchange%==N goto confirmdir
- if /i %destchange%==y goto setdir
- :setdir
- set /P dest=Enter Destination (Exclude trailing \):
- :confirmdir
- echo Destination directory is:
- echo %dest%
- set confirm=y
- set /P confirm=Is this correct? (Y/n):
- if /i %confirm%==n goto setdir
- if exist %dest% echo Folder exists, continuing.
- if not exist %dest% mkdir %dest% & echo Folder created, continuing.
- echo Copying will now begin.
- pause
- ::Copying files-
- ::For loop copies file, verifies file was copied,
- ::and removes file from source.
- for %%f in (Q:%source%\*) do (
- :recopy
- copy %%f %dest%\%%f
- if not exist %dest%\%%f goto recopy
- set /a count+=1
- del %source%\%%f
- echo copied !count! of %total%
- ping -n 1 -w 500 1.1.1.1 >nul
- )
- echo =======================Copying complete, continue to verification.========================
- pause
- ::Begin Verification
- set verify=0
- for %%v in (%dest%\*) do set /a verify+=1
- echo %total% files in source directory.
- echo %verify% files in destination directory.
- if %total%==%verify% echo It appears that this utility was successful.
- if not %total%==%verify% color 47
- if not %total%==%verify% echo It appears there has been an error, check for missing files.
- ::Un-Map drive
- net use /del Q:
- pause
- endlocal
Advertisement
Add Comment
Please, Sign In to add comment