[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 批处理怎样修改配置文件里面的字符串?

我有个配置文件里面有这样一段话
""""FTP initial directory=oo-xx""""

我想用批处理修改这段话的oo-xx部分如下
""""FTP initial directory=aa-zz""""

等于说其他都是不变的只有 oo-xx 是个变量
需求就是
不用查找oo-xx方法改变这个值 因为oo-xx中的xx每次都不一致
有没有其他更好的方法 把变量中的值直接替换掉oo-xx

附上配置文件:

  1. @set @n=0;/* & echo off
  2. cscript -nologo -e:jscript "%~0"<a.txt>b.txt
  3. pause & exit/b & rem */
  4. txt = WScript.StdIn.ReadAll();
  5. txt = txt.replace(/(""""FTP initial directory=)oo-\d+""""/ig, '$1aa-zz""""')
  6. WScript.Echo(txt)
复制代码

TOP

DAIC   还在吗

TOP

:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(

TOP

回复 7# DAIC


    已经上传了配置文件的附件

TOP

回复 6# natasall


    能否把原始文件压缩一下作为附件传上来。直接发内容的话可能被论坛丢掉一些格式信息。

TOP

回复 5# DAIC

{10//
Id={A06FA2C3-3F49-4F34-95E9-162E071F925C}
Name=bak_log
Disabled=true
Include subdirectories=true
Separated backups=true
Use archive attributes=true
Use VSC=false
Backup type=0
Full copies to keep=0
One full every=0
Source="1,F:\_backup","1,F:\Mysqlbak\somc"
Destination="2,""""""FTP host=aaa.xxx.com"""",""""FTP ID=update"""",""""FTP password=afadfazcv/fghdfghert/adfagvhgfhdf+dfgsdfg/rtghgh/adhgfghs+adfadfa/cvbxcvbxcv/iyuityuity/nmvbnmvnmvnmhfj/nmvbnmghjdfghdfg+ghjdfghjtyu=="""",""""FTP port=21"""",""""FTP initial directory=oo-72"""",""""FTP data port=0"""",""""FTP min port=0"""",""""FTP max port=0"""",""""FTP external IP="""",""""FTP passive=false"""",""""FTP passive use control host=false"""",""""FTP transfer time out=0"""",""""FTP listen timeout=10000"""",""""FTP read timeout=60000"""",""""FTP connection time out=20000"""",""""FTP use MLIS=true"""",""""FTP use HOST=true"""",""""FTP use IPv6=false"""",""""FTP use compression=false"""",""""FTP NAT fast track=false"""",""""FTP use UTF-8=false"""",""""FTP proxy=""""""""Proxy type=0"""""""",""""""""Proxy port=1080"""""""",""""""""Proxy host="""""""",""""""""Proxy ID="""""""",""""""""Proxy logon=true"""""""",""""""""Proxy password=PD+FTBSpR5p+P/BMY6kwmnY/m0wWqUSaAT+PTA2pQJp3P/NMGKlZmn4/jkxkqTKaaj+PTBSpRppyP/BMY6lDmgE/g0xhqTCaBD/LTCCpdJ4="""""""""""",""""FTP Force hidden files listing=false"""",""""FTP hidden file string=-la"""",""""FTP SSL=""""""""Use TLS=0"""""""",""""""""SSL method=3"""""""",""""""""SSL authentication=4"""""""",""""""""Data protection=0"""""""",""""""""SSL mode=3"""""""",""""""""Pass through=false"""""""",""""""""Verify depth=0"""""""",Peer=false,""""""""Fail if no peer=false"""""""",""""""""Client once=false"""""""",CCC=false,""""""""Certificate file="""""""",""""""""Cipher list="""""""",""""""""Root certificate="""""""",""""""""Key file="""""""",""""""""Verify directories="""""""""""",""""FTP Keep alive=false"""",""""FTP Keep alive time=120000"""",""""FTP Keep alive interval=120000"""",""""FTP stored files="""""""
Schedule type=1
Days of the week=1
Date/Time=0100000011100011111110110010010010101010101111110110101101110100
Days of the month=1
Month=0
Timer=180
Timer from=0100000011100011111110110000000000000000000000000000000000000000
Timer to=0100000011100011111110110001111111111111111111111111100111001001
Compression=2
Compress individually=false
Password protect=false
Split=0
Custom split size=4300000000
Password=afadfazcv/fghdfghert/adfagvhgfhdf+dfgsdfg/rtghgh/adhgfghs+adfadfa/cvbxcvbxcv/iyuityuity/nmvbnmvnmvnmhfj/nmvbnmghjdfghdfg+ghjdfghjtyu
Archive comment=Archive created by Cobian Backup 10
Encryption=0
Passphrase=afadfazcv/fghdfghert/adfagvhgfhdf+dfgsdfg/rtghgh/adhgfghs+adfadfa/cvbxcvbxcv/iyuityuity/nmvbnmvnmvnmhfj/nmvbnmghjdfghdfg+ghjdfghjtyu
Public key=
Include=
Exclude=
Pre-backup events=
Post-backup events="EXECUTE,F:\sof\del_backup.bat,"
Abort if pre-event fails=false
Abort if post-event fails=true
Mirror=false
Absolute paths=false
Always create top directory=true
Clear archive attributes=true
Include backup type=false
Impersonate=false
Abort if impersonation fails=false
Run as ID=
Run as password=afadfazcv/fghdfghert/adfagvhgfhdf+dfgsdfg/rtghgh/adhgfghs+adfadfa/cvbxcvbxcv/iyuityuity/nmvbnmvnmvnmhfj/nmvbnmghjdfghdfg+ghjdfghjtyu
Run as domain=.
//10}

这就是配置文件的全部内容

TOP

回复 3# natasall


BAT非常麻烦,需要你先把配置文件的完整内容发出来。

TOP

有高人帮忙吗。。谢谢各位大大

TOP

本帖最后由 natasall 于 2014-9-25 17:09 编辑

回复 2# DAIC


    自带的命令不行吗? 服务器上无法下载其他命令的

TOP

  1. sed -r "/FTP initial directory=/ s/(.*)=.*(....)$/\1=aa-zz\2/" a.txt > b.txt
复制代码

TOP

返回列表