Tech Support > Microsoft Windows > Help and Support > Batch file which takes user input
Batch file which takes user input
Posted by Nocturnal on December 13th, 2005


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?

--




Posted by Royce on December 13th, 2005


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.

"Nocturnal" wrote:

> 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?
>
> --
>
>
>
>
>

Posted by Nocturnal on December 13th, 2005


Thank you.

--
Nocturnal @ http://www.randomfix.com


"Royce" <Royce@discussions.microsoft.com> wrote in message
news:80E5AD0A-AB95-4118-B676-DA6D53FD74ED@microsoft.com...
> 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.
>
> "Nocturnal" wrote:
>
>> 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?
>>
>> --
>>
>>
>>
>>
>>



Posted by Royce on December 13th, 2005


your welcome...

"Nocturnal" wrote:

> Thank you.
>
> --
> Nocturnal @ http://www.randomfix.com
>
>
> "Royce" <Royce@discussions.microsoft.com> wrote in message
> news:80E5AD0A-AB95-4118-B676-DA6D53FD74ED@microsoft.com...
> > 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.
> >
> > "Nocturnal" wrote:
> >
> >> 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?
> >>
> >> --
> >>
> >>
> >>
> >>
> >>

>
>
>


Similar Posts