Create a Backup by extensions batch file for 15 points 1 hou
Create a Backup by extensions batch file for 15 points (~1 hour) as U06P
Goal: Demonstrate how to pass two parameters to create a directory and copy files from a passed path by a given extension to the backup directory of the same name.
Create a directory based on the first passed extension
Copy files by the first passed extension from the path of the second passed parameter into the newly created directory
Display the copied files to the user
Solution
U06P.bat:
@echo off
:: variables
set /P uname=Please enter the source directory name (like C:\\Users\\Downloads):
set /P drive=Please enter the backup directory name (like G:\\Backup):
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo ### Backing up the files..
%backupcmd% \"%uname%\" \"%drive%\"
:: use below syntax to backup other directories...
:: %backupcmd% \"...source directory...\" \"%drive%\\...destination dir...\"
echo Backup Complete!
@pause
