Computing.Net > Forums > Programming > Complex Bat File to Copy

Complex Bat File to Copy

Reply to Message Icon

Original Message
Name: Scizzy
Date: July 5, 2007 at 13:36:28 Pacific
Subject: Complex Bat File to Copy
OS: Xp
CPU/Ram: Sempron 2800+ // 1.2g DDR
Model/Manufacturer: Emachines M5405 Laptop
Comment:

Hey guys. I am pretty rough at making complex bat files. I have made plenty of simple ones to do copies of files and folders but I want another one.

I want to create a bat file to backup my user settings. ie "c:\documents and settings\owner"

...but this is what I can't figure out..

I want to the bat file to do this...

Prompt me what location to back up:

ie: What do you want to back up:
I put in C:\documents and settings\owner

Prompt me: Where do you want to back this up to:

I put in Z:\UserData Backup

and it does its thing!

Anyone know how to do that... I dont know how to even start this one!

Please help me!!!

Thanks a lot!


Report Offensive Message For Removal

Response Number 1
Name: Mechanix2Go
Date: July 5, 2007 at 14:06:27 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

@echo off
setLocal EnableDelayedExpansion

set /p src=copy from where?
set /p dest=to where?

echo xcopy !src! !dest!\



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: Scizzy
Date: July 5, 2007 at 14:17:59 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

I copied and Pasted exactly what you have and it doesn't copy. It is what i want, but it doesn't work. I tried Xcopy in the command prompt by itself to see if that works and it does... but it doesn't copy when in tha bat... help?

it just says this after i execute it...

Xcopy h: h:\backuptest

and nothing was copied!

Whats up?

Do i have to have the source and dest. in quotes?



Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: July 5, 2007 at 14:21:53 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

When you're satisfied, remove the echo from the last line. It's there for safety; so you can preview what it intends to do.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: July 5, 2007 at 14:24:40 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

If your paths have spaces your last line will beed to be:

xcopy "!src!" "!dest!\"



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 5
Name: Scizzy
Date: July 5, 2007 at 14:25:47 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

ya I replied to your answer, then I caught it and was like... duh!

THanks looks like it works, i just tried it... says it copied 97 files... now just need to find them... they aren't where I typed... will do some searching!

Thanks again!


Report Offensive Follow Up For Removal


Response Number 6
Name: IVO
Date: July 5, 2007 at 14:26:47 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

Remove the Echo in front of the XCopy to put it at work.

Do you know anything about batch scripting?
From your post I guess you have a long way to travel.


Report Offensive Follow Up For Removal

Response Number 7
Name: Scizzy
Date: July 5, 2007 at 14:36:02 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

No idea how to batch script. I do have a question about my batch though... It seems to be working... I will get as far as either, is this destination a file or folder, i put folder and it says copied X amount of files..

also, even if I type in cmd: xcopy h:\blah h:\blahbackup as a test

it will say X amount of files copied... but nothings in H:\blahbackup!

Whats going on, says it copied, but nothings in the dest. folder! Also, if this works correctly, will it create the DEST. folder if it doesnt exist..

Please help, this is wierd now!


Report Offensive Follow Up For Removal

Response Number 8
Name: Scizzy
Date: July 5, 2007 at 14:39:22 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

Example: Here is what the regular XCOPY command is doing in DOS:

C:\city codes\city.bmp -> C:\testcopy\city.bmp (Y/N)? y
C:\city codes\Index.138.pdf -> C:\testcopy\Index.138.pdf (Y/N)? y
C:\city codes\t10all.139.pdf -> C:\testcopy\t10all.139.pdf (Y/N)?
C:\city codes\t11c1-7.138.pdf -> C:\testcopy\t11c1-7.138.pdf (Y/N)
C:\city codes\t11c12-18.139.pdf -> C:\testcopy\t11c12-18.139.pdf (
C:\city codes\t11c19.138.pdf -> C:\testcopy\t11c19.138.pdf (Y/N)?
C:\city codes\t11c8-11.138.pdf -> C:\testcopy\t11c8-11.138.pdf (Y/
C:\city codes\t1all.138.pdf -> C:\testcopy\t1all.138.pdf (Y/N)? y
C:\city codes\t2all.138.pdf -> C:\testcopy\t2all.138.pdf (Y/N)? y
C:\city codes\t3all.138.pdf -> C:\testcopy\t3all.138.pdf (Y/N)? y
C:\city codes\t4all.138.pdf -> C:\testcopy\t4all.138.pdf (Y/N)? y
C:\city codes\t5all.139.pdf -> C:\testcopy\t5all.139.pdf (Y/N)? y
C:\city codes\t6all.138.pdf -> C:\testcopy\t6all.138.pdf (Y/N)? y
C:\city codes\t7all.138.pdf -> C:\testcopy\t7all.138.pdf (Y/N)? y
C:\city codes\t8all.138.pdf -> C:\testcopy\t8all.138.pdf (Y/N)? y
C:\city codes\t9all.138.pdf -> C:\testcopy\t9all.138.pdf (Y/N)? y
18 File(s) copied...

I check c:\testcopy\ and its empty! !


Report Offensive Follow Up For Removal

Response Number 9
Name: tonysathre
Date: July 6, 2007 at 14:19:46 Pacific
Subject: Complex Bat File to Copy
Reply: (edit)

Try this:

::==
@echo off
setLocal EnableDelayedExpansion

set /p src=copy from where?
set /p dest=to where?

xcopy /e !src! !dest!\
::==


"Computer security." — Oxymoron


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Complex Bat File to Copy

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software