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-13 17:16
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » How to judge that a TXT document is an empty document View 1,826 Replies 7
Original Poster Posted 2006-08-19 22:41 ·  中国 四川 联通
初级用户
Credits 20
Posts 8
Joined 2006-08-14 21:37
19-year member
UID 60527
Status Offline
How to judge that there is no content in a TXT document
Floor 2 Posted 2006-08-19 23:20 ·  中国 四川 成都 电信
初级用户
Credits 62
Posts 27
Joined 2006-08-02 17:41
20-year member
UID 59703
Status Offline
Floor 3 Posted 2006-08-20 00:46 ·  中国 四川 联通
初级用户
Credits 20
Posts 8
Joined 2006-08-14 21:37
19-year member
UID 60527
Status Offline
Floor 4 Posted 2006-08-23 00:14 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
What kind of document is considered an empty document? If only a document with no content is considered empty, then the method of judging the file size doesn't work, because if you enter N spaces and then save it, the file size must not be 0. At this time, you can only use the form of findstr. test.txt to judge the presence of content to get the correct answer.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 5 Posted 2006-08-23 09:43 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
The correct above

findstr . test.txt>nul&&echo No Empty||echo Empty
Floor 6 Posted 2006-08-23 14:07 ·  中国 辽宁 大连 教育网
中级用户
★★
DOS之友
Credits 332
Posts 168
Joined 2005-10-06 00:00
20-year member
UID 43171
Gender Male
From 天涯
Status Offline
Originally posted by namejm at 2006-8-23 00:14:
  What kind of document is considered an empty document? If no content is considered an empty document, then the method of judging the file size will not work, because if you enter N spaces and save it, the file size must not be 0...

I actually think that judging the file size is also okay. One is that a file with N spaces has a size.
So it is okay to use the size.
Second, even if the file size of N spaces is 0 bytes. Then such a file is also meaningless. So it can also be ignored
测试环境: windows xp pro sp2 高手是这样炼成的:C:\WINDOWS\Help\ntcmds.chm
Floor 7 Posted 2006-08-27 03:30 ·  中国 广东 深圳 电信
初级用户
Credits 30
Posts 17
Joined 2006-08-02 14:48
20-year member
UID 59680
Gender Male
Status Offline
What you said is all correct. A document with a size of 0 is generally meaningless, so it can also be regarded as an empty document
Floor 8 Posted 2006-08-27 07:42 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Originally posted by IceCrack at 2006-8-23 14:07:

I also think that judging the file size is also possible. A file with N spaces has a size.
So using the size is okay.
Second, even if the size of a file with N spaces is 0 bytes. Such a file is also meaningless. So it can also be ignored

  icracrack is wrong here. Now we are investigating the precise definition of an empty file, not the question of whether the file is meaningful or not—files with spaces but no other content are useful to some people, and at this time they are meaningful; but they are not useful to many people, and at this time they are not meaningful; whether they are meaningful or not is different for each person.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Forum Jump: