568数据 568数据


批处理备份文件夹和文件后发布文件夹至网站

网络编程 批处理备份文件夹和文件后发布文件夹至网站 06-21
先将"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

批处理一键关闭高危有害端口完整版(适合服务器使用)
注意:你的系统不一定支持ipseccmd,可以在cmd里试一下或者在下面代码的某句ipseccmd后另起一行加个pause看看报不报错!如果不支持,证明你安装的系统

用批处理程序修改 计算机名 工作组 计算机描述的代码
@echooffecho骏龙包装计算机名称、计算机描述、工作组修改批处理程序Echopausecls:set/pid=请输入本机网段号::set/pip=请输入本机IP地址::netshinterfaceipsetaddressname

CMD里或登陆远程linux服务器时命令行下复制和粘贴实现方法
如果要在CMD中复制的话,必须通过鼠标.复制:要先标记(在CMD中击鼠标右键)要复制的内容(或者称是范围),然后鼠标点击右键或按回车(或Ctrl+C)即可复制完


编辑:568数据

标签:备份,批处理,计算机,请输入,工作组