China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-04 08:51
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Very Large Text File View 894 Replies 7
Original Poster Posted 2007-04-24 03:46 ·  中国 广东 阳江 阳春市 电信
初级用户
Credits 72
Posts 27
Joined 2007-04-02 08:27
19-year member
UID 83702
Gender Male
Status Offline
I have several .txt text files here, and each one is very large, about 108MB. When I changed its extension to .xls, it actually told me it couldn't be fully loaded, because it exceeded 65,536 lines; when I changed it to .doc, it was even more outrageous — it actually showed more than 30,000 pages, and also said it exceeded Word's maximum page count!
Under DOS, is there any way to split one .txt into several .txt files?

[ Last edited by hrduan268 on 2007-4-24 at 08:15 AM ]
Floor 2 Posted 2007-04-24 09:24 ·  中国 广东 阳江 阳春市 电信
初级用户
Credits 72
Posts 27
Joined 2007-04-02 08:27
19-year member
UID 83702
Gender Male
Status Offline
http://www.cn-dos.net/forum/viewthread.php?tid=26345###
So someone had already done this before. I'll go back and try it first, then study it some more.
Floor 3 Posted 2007-04-24 09:50 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Actually, many of the questions being asked now;
had already been solved before
and can all be found by searching;
Floor 4 Posted 2007-04-24 10:48 ·  中国 广东 阳江 阳春市 电信
初级用户
Credits 72
Posts 27
Joined 2007-04-02 08:27
19-year member
UID 83702
Gender Male
Status Offline
I used 9527's program, but it didn't work:
@echo off&setlocal
for /f "tokens=1*" %%a in (fi.txt) do call :pp "%%a" "%%b"
goto :eof
:pp
if /i %1 equ "**BEGIN" (
>>%~2.txt echo %~1 %~2&set a=%~2.txt
) else (
>>%a% echo %~1 %~2
)
goto :eof
Maybe it isn't suitable for extra-long text files
Floor 5 Posted 2007-04-24 11:00 ·  中国 广东 阳江 阳春市 电信
初级用户
Credits 72
Posts 27
Joined 2007-04-02 08:27
19-year member
UID 83702
Gender Male
Status Offline
Using 无奈何's program, it works:
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%i in (spil.txt) do (
set tmp=%%i
if "!tmp:~0,7!" == "**BEGIN" (
set file=!tmp:*BEGIN =!
echo %%i>!file!
) else (
echo %%i>>!file!
)
)
I inserted things like **BEGIN FILE1 **END from the original text into the text file, and in total it needs to be split into 3 text files.
But after running for more than 30 minutes, the first text file to be split still wasn't finished (that is, the first END still hadn't appeared), so I stopped it. Then I changed this unfinished first text file to XLS, and it still said the line count was too large and it couldn't be fully loaded.
Looks like it has to be split into 40 text files, but manually adding **BEGIN FILE1 **END and so on is really troublesome. Just opening that 108MB text file alone takes several minutes. Is there any way!!

[ Last edited by hrduan268 on 2007-4-24 at 08:18 AM ]
Floor 6 Posted 2007-04-24 12:53 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Big sweat... such a huge text file, that's rare indeed!
Floor 7 Posted 2007-04-25 02:14 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Floor 8 Posted 2007-04-25 13:48 ·  中国 湖南 常德 电信
银牌会员
★★★
Credits 1,384
Posts 709
Joined 2005-10-29 22:22
20-year member
UID 44271
Status Offline
Simply unbelievable — that's 54 million characters. That's as much as 54 copies of Dream of the Red Chamber. What is it, anyway? I'm curious...
Forum Jump: