I want to create a batch file which copy the content of folder and paste it into another folder. Say
source: D:\backup\test
destination: D:\backup1
But here i want to create a subfolder into destination into which i can paste the file.
@echo off
:: variables
echo Backing up file
set /P source=Enter source folder:
set /P destination=Enter Destination folder:
set listfile=xcopy /L
set xcopy=xcopy /S/E/V/Q/F/H
%listfile% %source% %destination%
echo files will be copy press enter to proceed
pause
%xcopy% %source% %destination%
pause
The if not exist
checks to see if the directory exists. If it does not, mkdir
creates it.
@echo off
echo Backing up the file
set /p source=Enter source folder:
set /p destination=Enter destination folder:
if not exist %destination% mkdir %destination%
set listfile=xcopy /L
set xcopy=xcopy /S/E/V/Q/F/H
%listfile% %source% %target%
echo Files listed will be copied.
pause
%xcopy% %source% %destination%