Something Awesome Update
I found it difficult to implement xcopy specifically for batch files, not from the windows comman prompt line and could not find any documentations that switched between command prompt and batch files. I figured it might be easier to try looking for ways to backup files as a way to copy files and stumbled across this guide to back up files. This is the code section which does the backing up:
@echo off :: variables set drive=G:\Backup set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo ### Backing up email and address book (Outlook Express)... %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Address Book" "%drive%\Address Book" %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Identities" "%drive%\Outlook Express"
echo ### Backing up email and contacts (MS Outlook)... %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%\Outlook"
echo ### Backing up the Registry... if not exist "%drive%\Registry" mkdir "%drive%\Registry" if exist "%drive%\Registry\regbackup.reg" del "%drive%\Registry\regbackup.reg" regedit /e "%drive%\Registry\regbackup.reg"
:: use below syntax to backup other directories... :: %backupcmd% "...source directory..." "%drive%\...destination dir..."
echo Backup Complete! @pause
Below I have recreated a more simplified code to work with using the above as a guideline :
@echo off title Downloading Data :: variables set drive=E:\ set backupcmd=xcopy /s /c /d /e /h /i /r /y echo off %backupcmd% "%USERPROFILE%" "%/DRIVE%\test\backup" @echo off cls
Itās very similar to the guideline except I decided to changeĀ ā@pauseā withĀ āclsā which clears the screen. The code I recreated simply backs up everything in the computer just to simplify things. As previously mention @echo offĀ stops command prompt from displaying the command itself when executing and title sets the title for the command prompt window. Variable tells command prompt that we want to se the variables drive toĀ āE:\ā and backupcmd defines the command to be used (which in this case is xcopy).Ā I have implemented the code on Notepad and saved the batch file onto my USB drive as copy.bat, where my copied files will be stored in the folder i called ātestā and sub folderĀ ābackupā. The below picture is evidence that the batch file is able to copy files from my computer.
Of course copying everything from my computer would take forever, so I will begin to look at how to choose select folders and files next week. For now I plan on testing this on various computers.
















