I'm trying to write a batch file that is basically used for copying destinations. Now, I want to make it to where other people can use it without having to go in and edit the directories and destinations. Is there a way for me to write the batch file to where it prompts, asking for the directory the user would like to copy, and to ask for the drive that the user would like to copy it to?
This is what I've been using for a while now.
@echo off
:: variable
set backupdir="Destination"
set backupcmd=xcopy /e /h /f /y /v /c /i /r /g /k /d
echo.
echo +++ Backing Up Data +++
echo.
echo.
%backupcmd% "Directory\*.*" "%backupdir%\Data"
timeout /t 2
cls
echo Backup Complete
echo.
echo.
timeout /t 2
cls
echo.
echo +++ Now taking hidden and system attributes off of folders +++
echo.
echo.
echo.
attrib -s -h "Destination\Data"
echo.
echo.
timeout /t 3
And is there any way that I can improve this with using xcopy?
set /?
and see how to useSET /P variable=[promptString]
to obtain user input.%0
(for the actual program or command called) and%1-%9
for parameters passed. So you can create a new batch file with the linecall backup.bat c:\source c:\destination
and use%1
to reference source and%2
to reference destination. Not an answer because it doesn't handle prompting. Robocopy is a great tool as well for backup purposes and is standard on windows 7 install.