根据文件路径复制文件bat

来源:互联网 发布:淘宝网商店 编辑:程序博客网 时间:2024/05/22 06:13
rem MS-DOS batch filerem@echo offcls@echo [批处理程序说明]Title [批处理程序窗口标题]::批处理命令开始-----------------------------------set file=feifei.txtset isExist=0set 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 enabledelayedexpansionfor /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

原创粉丝点击