介绍:
提取指定的文件,进行系统增量部署。
脚本为windows平台下的bat文件
新建源文件:source\12\2.txt
, source\1.txt
创建目标文件夹:target
1.txt
12\2.txt
@echo off
cls
@echo [根据文件路径拷贝文件]
Title [根据文件路径拷贝文件]
set file=files.txt
set isExist=0
set bakDir=target
set source=source
for /f %%i in (%file%) do (
if not exist %source%/%%i (
echo %source%/%%i[不存在]
set isExist=1
)
)
if %isExist%==1 (
choice /c YN /M "有文件不存在,是否继续?"
if errorlevel==2 ( exit )
if errorlevel==1 ( goto doCopy )
)
:doCopy
for /f "tokens=1,2 delims=" %%i in (%file%) do (
if not exist %bakDir%\%%i (
md %bakDir%\%%i
)
echo f | xcopy %source%\%%i %bakDir%\%%i /s /y /f
)
pause::[提示按任意键结束...]
@echo off
set "source=source"
set "target=target"
xcopy %source% %target% /u /s /y
pause