ITPub博客

首页 > Linux操作系统 > Linux操作系统 > bat文件处理

bat文件处理

原创 Linux操作系统 作者:hexiaomail 时间:2010-05-18 11:05:20 0 删除 编辑

::此文件功能对vss系统数据按单个project作自动备份,在备份之前将对清单文件做相应处理
::1、删除所有空行
::2、删除行首和行尾
::3、用$/替换所有行中$
::4、备份VSS项目
@echo off

cls

set iPath=D:\C#Backup$\script\
set ldFile=%iPath%old.txt
set newFile=%iPath%new.txt
set listFile=%iPath%c#.txt
set TMPFILE=%random%.tmp

set SSDIR=D:\NetApplication\C#
ss Dir $/ -F- > %oldFile%

echo.

echo 正在处理,请稍等...

::删除第一行
if exist %listFile% (del %listFile%)
more +1 %oldFile% > %newFile%


::删除最后一行
if exist %oldFile% (del /f/q %oldFile%)
for /f "delims=:" %%i in ('findstr /n . %newFile%') do set n=%%i
set /a nm=%n% >nul
   for /f "delims=" %%i in ('findstr /n .* %newFile%') do (
        set /a mn=%%i 2>nul
        set "m=%%i"
        setlocal enabledelayedexpansion
        set "m=!m:*:=!"
 if !nm! EQU !mn! goto end
echo.!m!>>%oldFile%
endlocal
)
:end

::用$/替换$字符
if exist %newFile% (del /f/q %newFile%)
for /f "delims=:" %%i in ('findstr $ %oldFile%') do (
        set "m=%%i"
 setlocal enabledelayedexpansion
 set b=!m:$=$/!%
      echo !b!>>%newFile%
endlocal
)


::删除空行
for /f "delims=^" %%k in (%newFile%) do (if not %%k == "" echo %%k >> %listFile%)


::删除临时文件
if exist %oldFile% (del /f/q %oldFile%)
if exist %newFile% (del /f/q %newFile%)
echo.

for /f "delims=" %%a in ('findstr . %listFile%') do ssarc.exe -d- -s"D:\NetApplication\C#" -i-Y -yadmin,Fihvss123 -O@"D:\C#Backup%%aBak_%date:~0,10%.txt" "D:\C#Backup%%aBak_%date:~0,10%.ssa" %%a

ECHO 任务完成,请按任意键查看生成结果...

::pause >nul

::start %newFile%

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9932141/viewspace-662941/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: run_stats
请登录后发表评论 登录
全部评论

注册时间:2008-07-05

  • 博文量
    86
  • 访问量
    219972