How to compress files with a size of zero bytes using winrar

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
hacker
Posts: 6
Joined: 29 Aug 2014 06:21

How to compress files with a size of zero bytes using winrar

#1 Post by hacker » 29 Jan 2015 05:54

Hi

I have several files with a size of zero bytes that I want to compress them using compression tools. So that the files compressed with the same amount of current (current size:0 byte).
Please suggest a solution that solve my problem.

thanks in advance

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: How to compress files with a size of zero bytes using wi

#2 Post by dbenham » 29 Jan 2015 06:41

The "compressed" version of a 0 length file cannot be 0 because it must contain the name (and possibly the full path) of the file :!:

The original file has length 0 because the name (and path) is separate from the file itself.

This leads me to question something I never thought about before - How does the OS handle directory information with regard to reporting disk usage :?:


Dave Benham

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: How to compress files with a size of zero bytes using wi

#3 Post by Squashman » 29 Jan 2015 08:11

dbenham wrote:This leads me to question something I never thought about before - How does the OS handle directory information with regard to reporting disk usage :?:
Dave Benham

That is an intriguing thought. You would think it has to take up at least a couple of bits bytes just to catalog the file name in the file system.

I think we could test this theory just by creating a couple of zero byte files with really long file names. Then check the disk usage.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: How to compress files with a size of zero bytes using wi

#4 Post by Squashman » 29 Jan 2015 08:16

hacker wrote:Hi

I have several files with a size of zero bytes that I want to compress them using compression tools. So that the files compressed with the same amount of current (current size:0 byte).
Please suggest a solution that solve my problem.

thanks in advance

If you open a compressed file in a hex viewer you will see some header information. As Dave pointed out to, it shows the original file name that it compressed.

Code: Select all

00000000  50 4B 03 04 0A 00 00 00 00 00 E9 40 3D 46 00 00    PK........é@=F..
00000010  00 00 00 00 00 00 00 00 00 00 0C 00 00 00 7A 65    ..............ze
00000020  72 6F 62 79 74 65 2E 74 78 74 50 4B 01 02 14 00    robyte.txtPK....
00000030  0A 00 00 00 00 00 E9 40 3D 46 00 00 00 00 00 00    ......é@=F......
00000040  00 00 00 00 00 00 0C 00 24 00 00 00 00 00 00 00    ........$.......
00000050  20 00 00 00 00 00 00 00 7A 65 72 6F 62 79 74 65     .......zerobyte
00000060  2E 74 78 74 0A 00 20 00 00 00 00 00 01 00 18 00    .txt.. .........
00000070  A0 8D B9 E3 CC 3B D0 01 A0 8D B9 E3 CC 3B D0 01     ¹ãÌ;Ð. ¹ãÌ;Ð.
00000080  A0 8D B9 E3 CC 3B D0 01 50 4B 05 06 00 00 00 00     ¹ãÌ;Ð.PK......
00000090  01 00 01 00 5E 00 00 00 2A 00 00 00 00 00          ....^...*..... 


The PK is the initials of the creator of the zip file format. Phil Katz.

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: How to compress files with a size of zero bytes using wi

#5 Post by Samir » 02 Feb 2015 10:58

Squashman wrote:The PK is the initials of the creator of the zip file format. Phil Katz.
And PKware's headquarters a just a short drive from me. Ran into it by accident when I saw this building with a 'PKWARE' on it, but looked just like the non-chalant name of a building. It got me wondering, and after a quick Internet search, low-and-behold the building is the Pkware world headquarters. :shock:

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to compress files with a size of zero bytes using wi

#6 Post by foxidrive » 02 Feb 2015 16:05

Squashman wrote:That is an intriguing thought. You would think it has to take up at least a couple of bits bytes just to catalog the file name in the file system.


In the FAT file system you could create zero byte files and it would use no disk space, until an extra cluster was needed to expand the table because it used the last entry in the current block.

I don't know how the NTFS handles it though...

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: How to compress files with a size of zero bytes using wi

#7 Post by Ed Dyreen » 02 Feb 2015 19:49

dBenham wrote:This leads me to question something I never thought about before - How does the OS handle directory information with regard to reporting disk usage :?:
like FAT NTFS uses the Master File Table (MFT) to store metadata ( name, size, acces rights, directory structure, .. ).

Post Reply