找 Bat 或者 VBs高手

一.假如当前文本文件a.txt内容为:a1-a5,c2-c4,b1,b2"b3b4b5最终我要的文本文件b.txt内容为:a1a2a3a4a5c2c3c4b1b2b3b4... 一.假如当前文本文件a.txt内容为:
a1-a5,c2-c4,b1,b2"b3 b4 b5
最终我要的文本文件b.txt内容为:
a1
a2
a3
a4
a5
c2
c3
c4
b1
b2
b3
b4
b5
也就是说: 1.首先要查找字符- ,(注意-的前后并不一定仅局限于a或者b字符,可能还有其它字符),并自动补全其中省略的内容;(最好是给操作者一个提示看补全的内容对不对)
2.将文本中字符," 删除掉并换行;
3.把结果写入b.txt

二. 将b.txt与c.txt相比较, 将c.txt与b.txt第一列相同的内容筛选出来
例如:
c.txt b.txt
c1 25 m c1
c2 30 n c2
b1 1 m b2
b2 2 n
b4 3 m
最终筛选出的结果:m.txt 和n.txt
c1 25 c2 30
b2 2

--------------------------------------------------
这个估计太难,但我相信一定有高手可以实现,用VBS实现也可以!
展开
 我来答
314ccp
2009-06-14 · TA获得超过5625个赞
知道大有可为答主
回答量:1497
采纳率:0%
帮助的人:2151万
展开全部
@echo off
setlocal enabledelayedexpansion
echo 正在生成B.txt,请稍候......
del /q tmp.txt,b.txt,m.txt,n.txt >nul2>nul
for /f "delims=" %%a in (a.txt)do (
(set str=%%a&set str=!str:^"= !&set str=!str:,= !)
)&for %%b in (!str!)do (rem
)&echo/【%%b】|find "-"&&(
(set/a p=0&set c=&set e=0&set f=0&set s=)
for /f "tokens=1,2 delims=-" %%c in (
"%%b") do (set a=%%c&set/a t=0&call:pd&set "d=%%d"&call:xh)
)||echo/【%%b】&&echo %%b>>b.txt
echo.&echo 正在比较C.txt和B.txt,请稍候......
for /f %%i in ('type b.txt')do find "%%i" <c.txt>>tmp
echo.&echo 正在生成m.txt和n.txt,请稍候......
find "m" <tmp>>m.txt&find "n" <tmp>>n.txt
del tmp /q&echo.& pause
start b.txt
goto eof

:xh
set d=!d:%c%=!
for /l %%m in (0 1 10)do (
if "!b:~%%m,1!" == "0" (set/a e+=1) else goto jx)

:jx
for /l %%m in (0 1 10)do (
if "!d:~%%m,1!" == "0" (set/a f+=1) else goto jxa)

:jxa
set b=!b:~%e%,8!
set d=!d:~%f%,8!
for /l %%i in (!b! 1 !d!)do (
set s=0000%%i&set s=!s:~-%i%!
echo !a!!s!>>b.txt)
goto eof

:pd
for /l %%m in (0 1 10)do (
if "!a:~%%m,1!" neq "" (echo=!a:~%%m,1!|findstr "[0-9]">nul||set/a t=%%m)
)
set /a t+=1
set c=!a:~0,%t%!
set b=!a:%c%=!&set a=!c!
for /l %%n in (0 1 10) do if "!b:~%%n,1!" neq "" (
set/a i=%%n+1
if !p!==0 if "!b:~%%n,1!"=="0" set/a k+=1
if !p!==0 if "!b:~%%n,1!" neq "0" set/a p=1)
set/a p=0

:eof

头大的很!!!!!!!!!!!!!!!
winds504
2009-06-13 · TA获得超过374个赞
知道小有建树答主
回答量:283
采纳率:100%
帮助的人:373万
展开全部
' 1.VBS

set fs = CreateObject("Scripting.FileSystemObject")
set dict = CreateObject("scripting.dictionary")

infilePath = "D:\a.txt"

outfilePath = "D:\b.txt"

if Not fs.FileExists(infilePath) then
MsgBox "文件不存在"
WScript.Quit
end if

set rfile = fs.OpenTextFile(infilePath)
set wfile = fs.CreateTextFile(outfilePath, true)

do until rfile.atEndOfStream
content = rfile.ReadLine
char1=""
char2=""
num1=""
num2=""
bFirst=TRUE
for i=1 to Len(content)
c=Mid(content,i,1)
select case c
case "0","1","2","3","4","5","6","7","8","9"
if bFirst then
num1 = num1 & c
else
num2 = num2 & c
end if
case "-"
bFirst=False
case ","," ",""""
if bFirst then
wfile.WriteLine char1 & num1
else
if char1 = char2 then
for num1=CInt(num1) to Cint(num2)
wfile.WriteLine(char1 & num1)
next
else
wfile.WriteLine(char1 & "与" & char2 & "不匹配")
end if
end if

bFirst=TRUE
char1=""
char2=""
num1=""
num2=""
case else
if bFirst then
char1 = char1 & c
else
char2 = char2 & c
end if
end select
next
loop

if bFirst then
wfile.WriteLine char1 & num1
else
if char1 = char2 then
for num1=CInt(num1) to Cint(num2)
wfile.WriteLine(char1 & num1)
next
else
wfile.WriteLine(char1 & "与" & char2 & "不匹配")
end if
end if
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式