找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 25489|回复: 10

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

[复制链接]
发表于 2014-9-25 16:40:47 | 显示全部楼层 |阅读模式
我有个配置文件里面有这样一段话
""""FTP initial directory=oo-xx""""

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

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

附上配置文件:
发表于 2014-9-25 16:53:51 | 显示全部楼层
  1. sed -r "/FTP initial directory=/ s/(.*)=.*(....)$/\1=aa-zz\2/" a.txt > b.txt
复制代码
 楼主| 发表于 2014-9-25 16:58:13 | 显示全部楼层
本帖最后由 natasall 于 2014-9-25 17:09 编辑

回复 2# DAIC


    自带的命令不行吗? 服务器上无法下载其他命令的
 楼主| 发表于 2014-9-26 09:18:43 | 显示全部楼层
有高人帮忙吗。。谢谢各位大大
发表于 2014-9-26 10:37:17 | 显示全部楼层
回复 3# natasall


BAT非常麻烦,需要你先把配置文件的完整内容发出来。
 楼主| 发表于 2014-9-26 11:42:06 | 显示全部楼层
回复 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}

这就是配置文件的全部内容
发表于 2014-9-26 13:41:28 | 显示全部楼层
回复 6# natasall


    能否把原始文件压缩一下作为附件传上来。直接发内容的话可能被论坛丢掉一些格式信息。
 楼主| 发表于 2014-9-26 14:11:15 | 显示全部楼层
回复 7# DAIC


    已经上传了配置文件的附件
 楼主| 发表于 2014-9-27 10:21:40 | 显示全部楼层
:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(
 楼主| 发表于 2014-9-27 15:26:21 | 显示全部楼层
DAIC   还在吗
发表于 2014-9-27 17:35:23 | 显示全部楼层
  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)
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-19 20:33 , Processed in 0.019509 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表