Board logo

标题: 怎么全并文件呀,要求每行对齐!!再生成sql[已解决] [打印本页]

作者: akin520     时间: 2007-8-27 16:54    标题: 怎么全并文件呀,要求每行对齐!!再生成sql[已解决]

1.txt文件内容如下:
http://192.168.1.251/1.exe<<http://192.168.1.252/1.exe
http://192.168.1.251/2.exe<<http://192.168.1.252/2.exe
http://192.168.1.251/3.exe<<http://192.168.1.252/3.exe
http://192.168.1.251/4.exe<<http://192.168.1.252/4.exe
http://192.168.1.251/5.exe<<http://192.168.1.252/5.exe

2.txt文件内容如下:
http://192.168.1.253/1.exe
http://192.168.1.253/2.exe
http://192.168.1.253/3.exe
http://192.168.1.253/4.exe
http://192.168.1.253/5.exe

怎么样合并后,成为
http://192.168.1.251/1.exe<<http://192.168.1.252/1.exe<<http://192.168.1.253/1.exe
http://192.168.1.251/2.exe<<http://192.168.1.252/2.exe<<http://192.168.1.253/2.exe
http://192.168.1.251/3.exe<<http://192.168.1.252/3.exe<<http://192.168.1.253/3.exe
http://192.168.1.251/4.exe<<http://192.168.1.252/4.exe<<http://192.168.1.253/4.exe
http://192.168.1.251/5.exe<<http://192.168.1.252/5.exe<<http://192.168.1.253/5.exe

[ Last edited by akin520 on 2007-8-28 at 12:47 PM ]
作者: wudixin96     时间: 2007-8-27 19:02

@echo off
for /f "tokens=1* delims=:" %%i in ('findstr /n .* 1.txt') do (
  for /f "tokens=1* delims=:" %%a in ('findstr /n .* 2.txt') do (
    if %%i==%%a echo %%j^<^<%%b>>3.txt
  )
)

作者: akin520     时间: 2007-8-28 12:02
谢谢楼上的,,,和和,,你的FOR命令没看明白!!郁闷!
作者: akin520     时间: 2007-8-28 12:45    标题: 用批处理做成一件事,真爽呀,

@echo off
title     download_url地址全自动增加工具 by akin520
echo 请将数据的download_url导入,命名为1.txt,确认好后,请按回车!
pause >nul
echo 分出游戏单地址! 请按回车!
pause >nul
for /f "tokens=1* delims=<" %%a in (1.txt) do @echo %%a>>2.txt

echo 分出游戏名!请按回车!
pause >nul
for /f "tokens=7* delims=:/." %%a in (2.txt) do @echo %%a>>3.txt

echo 增加新的游戏地址!请按回车!
pause >nul
for /f "tokens=7* delims=:/." %%a in (2.txt) do @echo http://192.168.1.123/game/%%a.exe>>4.txt
for /f "tokens=7* delims=:/." %%a in (2.txt) do @echo http://192.168.1.21/game/%%a.exe>>5.txt

echo 合并新地址!请按回车!
pause >nul
for /f "tokens=1* delims=:" %%i in ('findstr /n .* 4.txt') do (
  for /f "tokens=1* delims=:" %%a in ('findstr /n .* 5.txt') do (  
    if %%i==%%a echo %%j^<^<%%b>>6.txt
  )
)

echo 合成全新地址!请按回车!
pause >nul
for /f "tokens=1* delims=:" %%i in ('findstr /n .* 1.txt') do (
  for /f "tokens=1* delims=:" %%a in ('findstr /n .* 6.txt') do (  
    if %%i==%%a echo %%j^<^<%%b>>7.txt
  )
)

echo 生成.sql文件!请按回车!
pause >nul
@echo off
for /f "tokens=1* delims=:" %%i in ('findstr /n .* 7.txt') do (
  for /f "tokens=1* delims=:" %%a in ('findstr /n .* 3.txt') do (
    if %%i==%%a echo update games set download_url='%%j' where game_name='%%b';>>sql.sql
  )
)

echo 完成,请按回车!
pause >nul
del 2.txt
del 3.txt
del 4.txt
del 5.txt
del 6.txt
del 7.txt

工具中需要的,,,想了N天了,用2楼的,,,终于搞定了!!
升级数据库用的,,,直接生成就可以用了,

[ Last edited by akin520 on 2007-8-28 at 12:46 PM ]