Creating batch file for backup

G

Guest

Hi all, I am trying to write a batch file to copy a folder to an external
hard drive. I have got the batch file working correctly, but when I plug in
the ext drive it is grabbing drive letter "g" all the time. I have set it
grab drive "z" but does not always do this. I would like to have the batch
file stop and ask what the drive letter is and then proceed using that drive
letter...is this at all possible? I have found the choice command but I don't
think that is available in WinXP...any help greatly appreciated. Cheers
 
A

Ayush

Use set command with p parameter. It will look like this :
set /p Variablename=
It will stop , you can enter the drive letter then press enter. Now the value of
Variablename will be what you typed.
You can type anything after the "=" sign, it will echo that, it will not affect the
variable. Like:
set /p Variablename=Type the drive letter:
--
Ayush [ Be ''?'' Happy ]

For any query, search > www.Google.com
Want to know about a term > http://en.wikipedia.org

Replied To :
-------------------------------------------------------------

: Hi all, I am trying to write a batch file to copy a folder to an external
: hard drive. I have got the batch file working correctly, but when I plug in
: the ext drive it is grabbing drive letter "g" all the time. I have set it
: grab drive "z" but does not always do this. I would like to have the batch
: file stop and ask what the drive letter is and then proceed using that drive
: letter...is this at all possible? I have found the choice command but I don't
: think that is available in WinXP...any help greatly appreciated. Cheers
 
P

Pegasus \(MVP\)

Anthony said:
Hi all, I am trying to write a batch file to copy a folder to an external
hard drive. I have got the batch file working correctly, but when I plug in
the ext drive it is grabbing drive letter "g" all the time. I have set it
grab drive "z" but does not always do this. I would like to have the batch
file stop and ask what the drive letter is and then proceed using that drive
letter...is this at all possible? I have found the choice command but I don't
think that is available in WinXP...any help greatly appreciated. Cheers

Try this:

@echo off
set /p Drive=Please enter the drive letter (e.g. Q:)
if "%Drive%"=="" goto :eof
xcopy %Drive%\*.* d:\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top