2014-11-19 3 views
1

폴더 내용을 복사하여 다른 폴더에 붙여 넣을 배치 파일을 만들고 싶습니다. 말해배치를 사용하여 폴더에 파일을 복사하여 붙여 넣는 방법

 source: D:\backup\test 
destination: D:\backup1 

여기 내가 파일을 붙여 넣을 수있는 대상에 하위 폴더를 만들고 싶습니다. 디렉토리가 존재한다면 아마도 당신을 도울 것입니다

@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 
+0

사용은 이미'xcopy' 명령에 대해 알고 있음을 시사한다. 이런 식으로 사용하는 것은 확실히 좋은 명령입니다. 지금까지 뭐 해봤 어? – SomethingDark

+0

한 폴더에서 다른 폴더로 데이터를 복사하는 배치 파일을 만들었습니다. 하지만 그 데이터를 대상에서 명령을 사용하여 생성해야하는 하위 폴더로 복사하려고합니다. –

+0

죄송합니다. 잘못된 파일을 붙여 넣었습니다. ... 이것은 내 배치 파일입니다. - @echo 해제 :: 반향 파일 설정/P source = 소스 폴더 입력 : set/P destination = Enter 대상 폴더 : 세트 listfile을 = XCOPY/L 세트 XCOPY = XCOPY/S/E/V/Q/F/H % 소스 %의 % 대상 % 에코 파일 복사 프레스 것 % 진행할 입력 % listfile을 일시 %의 XCOPY %의 % source % % 대상 % 일시 중지 –

답변

1

if not exist 확인합니다. 그렇지 않으면 mkdir가 생성됩니다. XCOPY 태그의

@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% 
1

...

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 
1
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 
관련 문제