# Solved: Zero-Byte File Question



## html81993 (Jul 8, 2005)

I am trying to create a 0-byte file in my current directory(running XP Home). I am reading "Harnessing DOS 6.0 Batch Files and Command Macro Power by Craig Menefee and Nick Anis". They talk about creating "zero-byte" files by using the following command.

```
REM > [path\][filename]
```
 They use the example

```
c:\>REM > EXAMPLE.FIL
```
 I am trying to create a zero-byte file using that command. Can anyone tell me how to get it to work?


----------



## Squashman (Apr 4, 2003)

The only way I was able to create a Zero Byte file at the cmd prompt in Windows 2000 was to use the Type command with a non existent file and pipe the output to a new file name.


```
C:\>type g$5asd > marker.txt
The system cannot find the file specified.

C:\>dir marker*
 Volume in drive C has no label.
 Volume Serial Number is 6C62-A1FF

 Directory of C:\

04/10/07  02:05a                     0 marker.txt
               1 File(s)              0 bytes
               0 Dir(s)  29,312,504,832 bytes free

C:\>
```


----------



## JohnWill (Oct 19, 2002)

COPY NUL C:\TEST.TXT

You'll get a zero length file.


----------



## JohnWill (Oct 19, 2002)

Squashman said:


> The only way I was able to create a Zero Byte file at the cmd prompt in Windows 2000 was to use the Type command with a non existent file and pipe the output to a new file name.


What in the world are you doing up at 3:00 AM? Don't you ever sleep?


----------



## html81993 (Jul 8, 2005)

JohnWill said:


> COPY NUL C:\TEST.TXT
> 
> You'll get a zero length file.


Thank you. That worked.


----------



## JohnWill (Oct 19, 2002)

*You can mark your own threads solved using the thread tools at the upper right of the screen.©*


----------



## Squashman (Apr 4, 2003)

JohnWill said:


> What in the world are you doing up at 3:00 AM? Don't you ever sleep?


It was only 2am cst and I was still at work.


----------



## JohnWill (Oct 19, 2002)

You need to get a day job.


----------



## ZeRealBigBoss (Mar 17, 2007)

write "copy con <yourfilename>" RETURN and then hit F6; you got a zero byte file. If you write one byte after the RETURN, you get a file length of 1 byte, two bytes gives two etc. F6 closes writes the file to disk and closes it


----------



## JohnWill (Oct 19, 2002)

I think the problem is already resolved.


----------



## acmetech (May 6, 2007)

I appreciate the extra tips, while I'm here. <g> I'm also thinking of the kid in another thread who's playing with this stuff.

Btw, instead of F6 I always used Control-Z. Neither's best... I guess they're both archaic.


----------



## Squashman (Apr 4, 2003)

JohnWill said:


> You need to get a day job.


Are you offering me one?


----------



## JohnWill (Oct 19, 2002)

Squashman said:


> Are you offering me one?


Nope!


----------

