Batch file which takes user input

N

Nocturnal

I'd like to create a batch file in which I type in a directory to copy using
XCopy and then a directory in which to save the files to using XCopy. Is
this possible with a batch file?

--
 
G

Guest

Try this:

@echo off
:dir_2_copy
cls
for /l %%i in (1,1,12) do echo.
set /p dir_2_copy=Enter the path of the directory you want to copy:
cd /d "%dir_2_copy%"
if %errorlevel% == 1 cls&echo.&echo The system cannot find the path
specified.&echo.&pause&goto dir_2_copy
:dir_2_save_2
cls
for /l %%i in (1,1,12) do echo.
set /p dir_2_save_2=Enter the path of the directory you want to save to:
cd /d "%dir_2_save_2%"
if %errorlevel% == 1 cls&echo.&echo The system cannot find the path
specified.&echo.&pause&goto dir_2_save_2
echo xcopy "%dir_2_copy%" "%dir_2_save_2%"

***lines that dont begin with 2 spaces have wrapped accidentally***
just remove the echo in the last line to copy the files. you might want to
type in "xcopy /?" in a comand prompt to see what parameters best fit the job
you are trying to preform.
 

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