Sign in with
Sign up | Sign in
Your question
Solved

Batch File to copy directory with if statements

Tags:
  • DOS Batch
  • Shell Script
  • Windows 7
Last response: in Windows 7
Share
October 1, 2013 10:29:33 AM

I'm trying to make a batch file for some new interns to use when they are doing a simple profile copy. I am pretty new when it comes to batching. I did a little bit back in the day but don't remember hardly any of it. Basically all the users are getting upgraded to new computers and I just want it to create a batch file that will copy the user's directory to an External HDD (E) and they move the External HDD to the new computer and copy the user's directory to the new computer. This is what I have so far and I'm pretty sure it's all jacked because it doesn't work, lol.

@echo off
set /p copyorrestore= Are you copying or restoring a profile? Enter 1. For Copy Enter 2. For Restore?
set /p user=Enter user's logon name?
if %copyorrestore%=="1" goto copy
if %copyorrestore%=="2" goto restore
:copy
COPY /G /S /Y C:\Users\%user% E:\
:restore
COPY /G /S /Y E:\%user% C:\Users\
pause
exit

More about : batch file copy directory statements

a b $ Windows 7
October 1, 2013 10:37:49 AM

Why not use USMT or the Transfer Wizard? User migration is precisely what they are there for.
m
0
l
October 1, 2013 10:57:01 AM

We are making so it's less interaction and interference as possible. Quick and no prompts. Login, double click, move to the next machine. So please can someone help. I realize there is a lot of software out there for this but this will also help improve my batching.
m
0
l
Related resources

Best solution

a b $ Windows 7
October 1, 2013 11:18:24 AM

All your batch does is move user data. USMT and the Transfer Wizard also migrate program and user settings, which will reduce the time necessary to migrate to a new system. A USMT environment can be pre-configured to run exactly as you are requesting (just double-click and move on). All it takes is a little up front time.

An example: I can connect 2 computers with a patch cable in a p2p configuration, launch my pre-built USMT tool on both, designate source/destination, click the "GO" button, and walk away. Networking is set up and user profiles are migrated (30GB in ~20 minutes on a 1Gig connection). At that point users can log in and all of their settings and customizations are intact (including wallpaper). Even .pst files are re-connected to Outlook (if there were any previously). No further hands on are required.
Share
October 1, 2013 11:35:36 AM

That sounds great, and I think I will go with that method on the second phase but I guess I did forget to mention one thing... they are moving from XP to 7 and a lot of the software preinstalled on the new machines images or either successors of the XP version or we decided to go to a totally new equivalent software. So user data is really all we are looking at moving at the time. But I will definitely use that when we do our Production and Marketing Dept. They are already on 7.
m
0
l
a b $ Windows 7
October 1, 2013 11:41:22 AM

USMT will migrate from XP to either Vista or Win 7, and from 32-bit to 64-bit (just not the other way). Even program settings from such things as Office 2007 to 2010/2013. You're actually doing things the hard way. Work smarter, not harder.
m
0
l
October 1, 2013 11:50:50 AM

OK, sweet! Then that sounds like the way to go then. I'm think I'll use that. Not really familiar with USMT but will allow it to save to an External and then restore to a new machine? We have a handful of programs that won't migrate I'm sure but that wouldn't be a big deal.
m
0
l
a b $ Windows 7
October 1, 2013 12:06:17 PM

Yes, it can do all that, and more. The reference is here: http://technet.microsoft.com/en-us/library/hh825256.asp...

Just be aware that the learning curve is somewhat steep. However, once you get your head wrapped around it you'll wonder how you ever got along without it. Also be aware that programs are not, and cannot be, migrated. Only settings, data, and user profiles are migrated.
m
0
l
October 1, 2013 12:11:12 PM

That shouldn't be a problem. We have program migration under control... the images of 7 will already have the programs preinstalled. We well figure out something else for the new programs that will be coming along. Thanks
m
0
l
!