rem MS-DOS batch file
rem
@echo off
cls
@echo [批处理程序说明]
Title [批处理程序窗口标题]
::批处理命令开始-----------------------------------
set file=feifei.txt
set isExist=0
set bakDir=feifei\
for /f %%i in (%file%) do (
if not exist %%i (
echo %%i[不存在]
set isExist=1
)
)
if %isExist%==1 (
choice /c YN /M "有文件不存在,是否继续?"
if errorlevel==2 ( exit )
if errorlevel==1 ( goto doCopy )
)
:doCopy
setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=:" %%i in (%file%) do (
set fPath=%%j
set fPath=!fPath:/=\!
set source=%%i:!fPath!
:: 目标文件
set dPath=%bakDir%!fPath:/=\!
rem 替换/为:\
echo !fPath! | findstr \.>nul
if errorlevel==1 (
::生成目录
md !dPath!
) else (
::生成文件
echo a | echo f | xcopy !source! !dPath! > nul
)
echo !source!
)
::批处理命令结束-----------------------------------
pause::[提示按任意键结束...]
把脚本放在feifei.bat,
再新建feifei.txt,存放要复制文件的路径
运行脚本feifei.bat