How to create or overwrite 0 byte file

Andy

Administrator
This can be very useful especially when you try to overwrite a file and preserve all of the original file permission, while on the destination has no enough disk space.

The solution is to use the old school 'copy con' command, then CTRL+Z to save the 0 byte:
Rich (BB code):
C:\Users\Public\Documents\Hyper-V\Virtual hard disks>dir
Volume in drive C is 120GB-SSD-INTEL-535
Volume Serial Number is 5AA1-FA13

Directory of C:\Users\Public\Documents\Hyper-V\Virtual hard disks

30/08/2019  11:16 AM    <DIR>          .
30/08/2019  11:16 AM    <DIR>          ..
30/08/2019  11:24 AM    28,726,788,096 ELIM.vhdx
30/08/2019  11:16 AM         7,856,128 ELIM_0C4D321A-57C2-406D-B109-D40E3489515F.hrl
30/08/2019  11:16 AM                 0 ELIM_D8D8EB69-E2A3-466A-B021-6862B016A5F2.hrl
30/08/2019  11:07 AM    44,396,707,840 JORDAN.vhdx
               4 File(s) 73,131,352,064 bytes
               2 Dir(s)  14,768,205,824 bytes free

C:\Users\Public\Documents\Hyper-V\Virtual hard disks>copy con JORDAN.vhdx
^Z
Overwrite JORDAN.vhdx? (Yes/No/All): Y
        1 file(s) copied.

C:\Users\Public\Documents\Hyper-V\Virtual hard disks>
The example above was to make JORDAN.VHDX to 0 byte while preserving all of it's original NTFS permission as I ran out of disk space, so I can overwrite JORDAN.VHDX with the replica file.

I hope this article is useful for all of us 🍻
 
Top