运维DOS脚本

--拷贝文件到指定目录

rem 获取前一天的备份
set today=%date:~8,2%
set /a day=%today%-1
set yesterday=%date:~0,4%-%date:~5,2%-%day%
rem copy目录F:\testcopy所有txt文件到F:\testcopy01
forfiles /p F:\testcopy /s /M *.txt /D +%yesterday% /C "cmd /c xcopy /Y @path F:\testcopy01"
rem 清理N天前备份
forfiles /p F:\testcopy01 /s /M *.txt /D -2 /C "cmd /c del /Q @path"

--输出文件中最后一行的最后一列

@echo off
set date=%date:~0,4%%date:~5,2%%date:~8,2%
rem clients相关数据输出到e:\result.txt,>覆盖源文件,>>追加文件
type e:\VT_Sys%date%.txt | findstr "clients" > e:\result.txt
set filePath=e:\result.txt
for /f "delims=: tokens=4" %%i in (%filePath%) do (set lastLine=%%~i)
rem 把最后一行以:分隔,只把最终数字数据输出到result.txt文件
echo %lastLine% >  e:\result.txt
 

你可能感兴趣的:(DOS命令)