Britec Tech Support Forum

Full Version: How to copy data from one Hard Drive to another using Robocopy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Robocopy is one of the 'inbuilt' tools (introduced in Vista and server 2008 but has been in the Windows NT Resource Kit since 1997) I have used hundreds of times to copy data from an old computer to a new one and the customer wanted to have their data re-instated onto the new computer.
(DISCLAMER: I have never used robocopy in windows 8. some information may not apply)

The reasons I copy the old hard drive to the new one is:
1. If the old drive is damaged (and I don't know it at that time) I may only have a short time to get the data off it.
2. If I forget to copy something into the correct place or the customer throws me a curve ball in a week (some random game their grandson installed on the computer doesn't have his saved games on it anymore and is throwing a hissy fit) I don't have to rely on them still having the old hard drive.

I don’t open command prompt and type the command each and every time, I use a batch script to do my dirty work.
And here goes.


Code:
@echo off


:drivefrom
echo *************************************
echo What is the drive letter that you are copying from?
set /p df=Drive Letter from:
set df=%df:~0,1%

:driveto
echo *************************************
echo What is the drive letter that you are copying to?
set /p dt=Drive Letter to:
set dt=%dt:~0,2%

:folder
echo *************************************
echo What was the old drive letter?
set /p fdl=old drive letter:
set fdl=%fdl:~0,3%

:START
SET robo_path=robocopy.exe
SET what_to_copy=/COPY:DAT /B /mir
SET exclude_dirs=/XD "Temporary Internet Files" "Cache" "Recent" "Cookies" "IETldCache" "iPod Photo Cache" "MachineKeys" "Default User" "LocalService" "NetworkService" "My Recent Documents" "NetHood" "PrintHood" "SendTo" "Templates"
SET exclude_files=/XF "pagefile.sys" "hiberfil.sys" "*.dmp"
SET options=/R:1 /W:0 /NFL /NDL /E /XJ

%robo_path% %df%: %dt%":\_"%fdl%_Drive.old %what_to_copy% %options% %exclude_dirs% %exclude_files%

:attrib
echo *************************************
echo would you like to change the attributes on the %dt%:\_%fdl%_Drive.old folder?
set /p userinp=attrib or not (Y or N):
set userinp=%userinp:~0,1%
if "%userinp%"=="Y" goto attribY
if "%userinp%"=="y" goto attribY
if "%userinp%"=="N" goto attribN
if "%userinp%"=="n" goto attribN
echo Invalid Choice
goto attrib

:attribY
attrib -s -r -h %dt%":\_"%fdl%_Drive.old /s /d
goto end

:attribN
:end
pause

This script asks 4 questions.
Q1 "What is the drive letter that you are copying from?"
Q2 "What is the drive letter that you are copying to?"
Q3 "What was the old drive letter?"
The reason for the third question is that on more than one occasion I have had more than one drive/partition to copy.
Once it has finished coping the data it asks if you want to change the destination folder an all sub folders to no longer be hidden (don’t ask why it is hidden when copied, it has always just done that from the first time I ran this script).

This script copies the data to a folder called (question 2 answer):\_(question 3 answer)_Drive.old

I hope that this helps someone,

AboodY
This looks interesting, still today I find batch files amazing, they make life so much easier, thanks for sharing.
windows 7 and it worked saved it to notepad as a .bat thanks
I think I have written 30 or 40 batch files in the past 5 years. You do one thing for one customer and you don't think much of it, you do it for 15 others and you realize just how useful it is to have it in a batch script and how much time you save.

Aboody
(09-11-2014, 03:48 AM)AboodY Wrote: [ -> ]I think I have written 30 or 40 batch files in the past 5 years. You do one thing for one customer and you don't think much of it, you do it for 15 others and you realize just how useful it is to have it in a batch script and how much time you save.

Aboody

Yeah I have used Batch files for years, great way of doing things faster.
Very handy to have. This reminds me of Shadow Copy.

https://www.runtime.org/shadow-copy.htm
Keep them coming guys all good stuff thanks.
Runtime make some great software, been using there stuff for years, I find there data recovery tool one of the best to recover data.