批处理备份文件夹和文件后发布文件夹至网站
技术  /  管理员 发布于 8年前   541
先将"C:\网站"下对应"D:\工程1"下面的所有文件夹和文件备份到"D:\备份2012-9-1-52647",然后再把"D:\工程1"发布到"C:\网站"。
用法:
backupAndPublish.bat "D:\工程1"
复制代码 代码如下:
@echo off
set SourceDir=%1
set now=%date:~0,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%%time:~3,2%%time:~6,2%
::参数
set DestDir="C:\网站"
set BackDir="D:\备份%now%"
echo.
echo 正在备份
call:Backup %SourceDir% %DestDir% %BackDir%
echo.
echo 正在发布
call:Publish %SourceDir% %DestDir%
goto :eof
:: 主程序
:Backup
setlocal enabledelayedexpansion
set SourceDir=%~1
set DestDir=%~2
set BackDir=%~3
:: 计算源路径长度
set SourceDirLen=0
set SourceDirStr=%SourceDir%
:next1
if not "%SourceDirStr%"=="" (
set /a SourceDirLen+=1
set "SourceDirStr=%SourceDirStr:~1%"
goto :next1
)
:: 备份
for /r "%SourceDir%" %%i in (*.*) do (
set BackPath=%%~dpi
set BackPath=%BackDir%!BackPath:~%SourceDirLen%!
set DestPath=%%i
set DestPath=%DestDir%!DestPath:~%SourceDirLen%!
set BackFilePath=%%i
set BackFilePath=%BackDir%!BackFilePath:~%SourceDirLen%!
echo !DestPath!
xcopy "!DestPath!" "!BackPath!" /r /y >nul 2>nul
if not exist "!BackFilePath!" (echo 备份复制失败)
)
for /r "%SourceDir%" %%i in (\) do (
set SourcePath=%%i
set SourcePath=!SourcePath:~0,-1!
set BackPath=%BackDir%!SourcePath:~%SourceDirLen%!
md "!BackPath!" >nul 2>nul
)
setlocal disabledelayedexpansion
goto :eof
:: 发布
:Publish
set SourceDir=%1
set DestDir=%2
xcopy %SourceDir% %DestDir% /r /y /i /e
goto :eof
test1 在
opencode + Oh-my-openagent,我的第一个免费的ai编程智能体管家:Sisyphus中评论 test..122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..Zita 在
Google AI Studio升级全栈 vibe coding体验,可直接构建带登录和数据库的应用中评论 111222..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号
