Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create file with 0 bytes (length) ?

974 views
Skip to first unread message

Dennis Halver

unread,
Jul 6, 2009, 5:41:09 PM7/6/09
to
How can I create a file with 0 byte length?

Dennis

Tim Meddick

unread,
Jul 6, 2009, 9:18:22 PM7/6/09
to
To create a file with length of 0 [zero] bytes in length type :

echo. > TEST.TXT


...at the 'Command Prompt' (any dos version)

Then type :

edit.com /79 TEST.TXT

and delete the space and the two odd characters.

Save the file and exit EDIT.COM


Alternatively, use any other binary text editor do delete the CR+LF
end-of-line (return) characters to make the file 0 [zero] bytes.

==

Cheers, Tim Meddick, Peckham, London. :-)


"Dennis Halver" <ha...@persrec.com> wrote in message
news:4a526f74$0$32682$9b4e...@newsspool2.arcor-online.net...

Tim Meddick

unread,
Jul 6, 2009, 9:22:18 PM7/6/09
to
Alternatively still; download the small but powerful XECHO.COM utility.

Then the command :

xecho #P >Test.txt

Will Not include the CR+LF linefeed 'characters' in creating the
'Test.txt' file

Xecho.com is available at :

http://hp200lx.net/cgi-bin/count-redir.cgi?dbname=xecho133.zip&URL=http://www.hp200lx.net/anonftp/pub/xecho133.zip

==

Cheers, Tim Meddick, Peckham, London. :-)


"Tim Meddick" <timme...@gawab.com> wrote in message
news:h2u7pi$mr$1...@aioe.org...

foxidrive

unread,
Jul 6, 2009, 9:48:45 PM7/6/09
to
On Tue, 7 Jul 2009 02:22:18 +0100, "Tim Meddick" <timme...@gawab.com>
wrote:

>Alternatively still; download the small but powerful XECHO.COM utility.
>
>Then the command :
>
>xecho #P >Test.txt

>> To create a file with length of 0 [zero] bytes in length type :
>> echo. > TEST.TXT


>> and delete the space and the two odd characters.


Is there something wrong with this on the on-topic OS?

rem>file.txt

Todd Vargo

unread,
Jul 7, 2009, 1:09:53 AM7/7/09
to

Considering that only the regulars of this group actually know what
"on-topic OS" means, this may be considered an Outsider antic. ;-)

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Harlan Messinger

unread,
Jul 7, 2009, 3:12:35 PM7/7/09
to

Other than the fact that it has no effect? (Have you tried it?)

Sjouke Burry

unread,
Jul 7, 2009, 3:18:35 PM7/7/09
to

rem "" >a.txt (tested)

Harlan Messinger

unread,
Jul 7, 2009, 4:16:03 PM7/7/09
to

Hmm. It sure doesn't work on my machine (Vista, 64-bit).

T Lavedas

unread,
Jul 7, 2009, 4:19:37 PM7/7/09
to
On Jul 7, 3:12 pm, Harlan Messinger
<hmessinger.removet...@comcast.net> wrote:
> foxidrive wrote:
> > On Tue, 7 Jul 2009 02:22:18 +0100, "Tim Meddick" <timmedd...@gawab.com>

> > wrote:
>
> >> Alternatively still; download the small but powerful XECHO.COM utility.
>
> >> Then the command :
>
> >> xecho #P >Test.txt
>
> >>> To create a file with length of 0 [zero] bytes in length type :
> >>> echo. > TEST.TXT
> >>> and delete the space and the two odd characters.
>
> > Is there something wrong with this on the on-topic OS?
>
> > rem>file.txt
>
> Other than the fact that it has no effect? (Have you tried it?)

foxidrive's approach works in 'true' DOS based OSs, like DOS 6.2,
Win9x and Win Me. It no longer works in WinNT+. However, I believe
the following will work in (nearly?) all OSs ...

set nul=>test.txt

The name of the variable is not particularly important - only that it
should not exist, unless the intent is to remove it from the current
environment.

Tom Lavedas
***********
http://there.is.no.more/tglbatch/

Harlan Messinger

unread,
Jul 7, 2009, 4:40:04 PM7/7/09
to
T Lavedas wrote:
> On Jul 7, 3:12 pm, Harlan Messinger
> <hmessinger.removet...@comcast.net> wrote:
>> foxidrive wrote:
>>> On Tue, 7 Jul 2009 02:22:18 +0100, "Tim Meddick" <timmedd...@gawab.com>
>>> wrote:
>>>> Alternatively still; download the small but powerful XECHO.COM utility.
>>>> Then the command :
>>>> xecho #P >Test.txt
>>>>> To create a file with length of 0 [zero] bytes in length type :
>>>>> echo. > TEST.TXT
>>>>> and delete the space and the two odd characters.
>>> Is there something wrong with this on the on-topic OS?
>>> rem>file.txt
>> Other than the fact that it has no effect? (Have you tried it?)
>
> foxidrive's approach works in 'true' DOS based OSs, like DOS 6.2,
> Win9x and Win Me. It no longer works in WinNT+.

OK, granted, I know the name of the group has "msdos" in it, but I
really wasn't thinking in terms of people using actual DOS any more. :-)

> However, I believe
> the following will work in (nearly?) all OSs ...
>
> set nul=>test.txt
>
> The name of the variable is not particularly important - only that it
> should not exist, unless the intent is to remove it from the current
> environment.

It does indeed work in the Vista command prompt window!

Tim Meddick

unread,
Jul 7, 2009, 8:19:24 PM7/7/09
to
I think that is what "Foxidrive" and "Todd Vargo" were talking about
when they commented over my post with :-

"on-topic OS"

...it is for this reason that I attempted, in my clumsy way, to try and
explain why it is a seemingly 'empty' file often has a size of 3
bytes...

Even if I had known of (rem >test.txt) I don't think I would have quoted
it as (despite the comments) my explanation was simple enough, while
still being concise, AND was relevant in ALL OS-es .

==

Cheers, Tim Meddick, Peckham, London. :-)


"Harlan Messinger" <hmessinger...@comcast.net> wrote in message
news:7bhq55F...@mid.individual.net...

T Lavedas

unread,
Jul 8, 2009, 8:06:32 AM7/8/09
to
On Jul 7, 4:19 pm, T Lavedas <tglba...@cox.net> wrote:
> On Jul 7, 3:12 pm, Harlan Messinger
>
>
>
> <hmessinger.removet...@comcast.net> wrote:
> > foxidrive wrote:
> > > On Tue, 7 Jul 2009 02:22:18 +0100, "Tim Meddick" <timmedd...@gawab.com>
> > > wrote:
{snip}

>  However, I believe the following will work in (nearly?) all OSs ...
>
>   set nul=>test.txt
>
> The name of the variable is not particularly important - only that it
> should not exist, unless the intent is to remove it from the current
> environment.
>
> TomLavedas
> ***********

As a followup; it occurs to me that the following is a safer way to
achieve the desired result ...

set nul=%nul%>test.txt

Structuring it this way insures that the environment remains
unchanged, regardless of the status of the environment before the
statement is issued.

Tom Lavedas
***********

Message has been deleted

T Lavedas

unread,
Jul 8, 2009, 12:52:18 PM7/8/09
to
On Jul 8, 11:27 am, Jawade <Henk_Jaw...@hotmail.com> wrote:
> Op Woensdag 8 Juli 2009 05:06:32 -0700 (PDT), schreef T Lavedas <tglba...@cox.net> in artikel <ef2919aa-93e9-47fb-92e4-bd9b5c6cd...@a7g2000yqk.googlegroups.com>:

>
>
>
> > As a followup; it occurs to me that the following is a safer way to
> > achieve the desired result ...
>
> >    set nul=%nul%>test.txt
>
> > Structuring it this way insures that the environment remains
> > unchanged, regardless of the status of the environment before the
> > statement is issued.
>
> What about:
>
>     rd>test.txt
>
> --
> Met vriendelijke groeten, Jawade.             Kolibrie Software Tools:http://jawade.nl/  1 juni: HexEditor, Diskeditors met MBR-rebuilders!
> Bootmanager (+Vista +Linux +Engels), ClrMBR, SDir(DIRsize), POP3lezer,
> Console-filebrowser, Kalender, Webtellers en IP-log, USB-stick tester.

That throws an error on my XPPSP3 machine.

It appears the OP multi-posted and this same topic is covered in great
detail over in alt.msdos.batch.nt, where the shortest approach I've
seen to far is ...

cd.>test.txt

That should work in pretty nearly all MS OSs.

Tom Lavedas

Zaphod Beeblebrox

unread,
Jul 8, 2009, 1:58:52 PM7/8/09
to

"T Lavedas" <tglb...@cox.net> wrote in message
news:1cf74c95-922f-45b6...@t21g2000yqi.googlegroups.com...

>
> It appears the OP multi-posted and this same topic is covered in
> great
> detail over in alt.msdos.batch.nt,
>
Actually, he (yet again) crossposted and silently set followups to
AMBNT, and somewhere along the line the followup group got broken /
ignoted so that (yet again) the conversation got fragmented among the
various groups.

OP, if you are out there and reading this message, please do us the
courtesy of allowing the multipost to do what it was intended to do,
or at the very least indicate in the original post that you've set
followups to a specific group.

--
Zaphod

No matter where you go, there you are!


Tim Meddick

unread,
Jul 9, 2009, 1:32:39 AM7/9/09
to
It throws an error on MY xpSP3 machine too! [ "The syntax of the command
is incorrect." ]

However, it also creates the file "Test.txt" with 0 [zero] bytes!

==

Cheers, Tim Meddick, Peckham, London. :-)

"T Lavedas" <tglb...@cox.net> wrote in message
news:1cf74c95-922f-45b6...@t21g2000yqi.googlegroups.com...

0 new messages