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

TOP

24# zm900612


不行,最后剩个括号!

TOP

20楼似乎在和1.txt之间漏了个空格
试试:
  1. @echo off
  2. (for /f "delims=" %%a in ('type 1.txt') do echo (%%a^))>456.txt
复制代码

TOP

21# zm900612


搞错了,源文件是unicode编码的

TOP

哦 错了 错了 编码是unicode编码的文件

TOP

不可能是编码问题,bat本来就是为ansi而生的...看来for也有极限啊...
有一个思路,没试验过:
  1. copy 1.txt 2.txt
  2. fsutil file setzerodata offset=0 length=20000000 1.txt
  3. fsutil file setzerodata offset=20000000 length=30000000 2.txt
复制代码
然后分别处理1.txt和2.txt,不过只有在ntfs格式的盘上才可以这样,而且也不确定fsutil能不能处理这么大的文件,毕竟这体积有点极端了...

TOP

19# zm900612



文件我传不上来,太大了,每行的内容都是一致的,大致就是这样的
56128485220, 248053, 3, "2011-03-28 23:58:46", "2011-03-29 00:00:14", "119.1.17.209", 0, 0(有N行,这是程序产生的日志文件)
我就是想把这个文件的内容读出来,然后输入到另外一个文件里面,格式就是在每行内容上面加上(内容),我最快四十的代码是
for /f %%i in ('more 1.txt') do echo ^(%%i^),>456.txt
后面看more不能显示出全部内容就改用type
for /f %%i in ('type1.txt') do echo ^(%%i^),>456.txt
还是不行,刚刚用了你写的这个代码,另外新建一个记事本把原来的内容复制进去,用你的代码是可以的,但是源文件就不行了,应该是编码问题吧

TOP

这样猜谜很困难,能否贴出你的目录树、测试代码、结果呢?

TOP

本帖最后由 hucuibai 于 2011-3-31 17:02 编辑

16# zm900612


你这个不行,你试试把你的文件另存为ansi编码的 然后再运行你写的,读不出内容,文件是空的!!

TOP

zm900612 大哥强悍!!!!!!!!

TOP

  1. @echo off
  2. (for /f "delims=" %%a in (1.txt) do echo (%%a^))>456.txt
复制代码

TOP

14# zm900612


哦 这是失误,源文件有的!

TOP

12楼是代码错了吧,【>456.txt(】这里似乎少一个空格

TOP

本帖最后由 hucuibai 于 2011-3-31 16:27 编辑

"2011-3-29 0:0:35",1,56129910365,56148967108,5008,71,3,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
"2011-3-29 0:0:35",1,56129910365,43205880120,112008,76,3,0,5,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
"2011-3-29 0:0:35",1,56129910365,56148710277,25008,73,3,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
"2011-3-29 0:0:35",1,56129910365,56149345836,102023,72,4,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
"2011-3-29 0:0:35",1,56129910365,77733315566,132008,74,3,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
"2011-3-29 0:0:35",1,56129910365,56151401567,80001,60,3,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
"2011-3-29 0:0:35",1,56129910365,77762226858,820108,75,2,1,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0

文件内容都是这种格式的,内容有四十多M 我想输出以后得到 ("2011-3-29 0:0:35",1,56129910365,77762226858,820108,75,2,1,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0),这种格式的的另外一个文件,文件是ansi编码的!

TOP

本帖最后由 hucuibai 于 2011-3-31 16:50 编辑

11# zm900612
  1. @echo off
  2.     for /r F:\123 %%i in (*.txt) do (
  3. >456.txt (
  4.         for /f %%a in ('type %%i') do echo ^(%%a^)^,
  5. )
  6. )
  7. pause
复制代码
貌似这样不行

TOP

返回列表