Reputation: 29
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
Upvotes: 1
Views: 10208
Reputation: 29
this is my script which i got success..
@echo off
:: variables
echo Backing up file
set /P source=Enter source folder:
set /P destination=Enter Destination folder:
set /P Folder=Enter Folder name:
@echo folder=%folder%
mkdir %destination%\%folder%
set xcopy=xcopy /S/E/V/Q/F/H/I
%xcopy% %source% %destination%\%folder%
echo files will be copy press enter to proceed
pause
Upvotes: 1
Reputation: 14304
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%
Upvotes: 1
Reputation: 714
That will help you maybe...
set FOLDER_CURRENT=%cd%
set VERSION= what u want
set FOLDER_SRC= what u want
set FOLDER_OUT= what u want
mkdir %FOLDER_OUT%
echo * Create the file xcopy_EXCLUDE.txt in order to ignore some file and directory.
echo * - ignore all .au3 files
echo * - ignore all .pspimage files
echo * - ignore the \psp\ directory
echo .au3 > xcopy_Exclude.txt
echo .pspimage >> xcopy_Exclude.txt
echo \psp\ >> xcopy_Exclude.txt
echo * The file xcopy_EXCLUDE.txt is created.
echo.
echo * Copy files with xcopy.
xcopy "%FOLDER_SRC%" "%FOLDER_OUT%" /E /H /Y /EXCLUDE:xcopy_Exclude.txt
echo * Files and directory are copied.
echo.
echo * Delete xcopy_Exclude.txt.
del xcopy_Exclude.txt
Upvotes: 1