简体   繁体   English

压缩不同文件夹中的大量小文件

[英]compress large amount of small files in different folders

In our appliation,we save some images in different folders like: 在我们的应用程序中,我们将一些图像保存在不同的文件夹中,例如:

1
2
3
4
...
500
...

And inside each folder there are large amount of images whose size is (5kb-20kb). 并且在每个文件夹中有大量图像,其大小为(5kb-20kb)。

Now we found that when we try to transfer these files,we have to compress them first using the winrar,however it cost toooooo much time!! 现在我们发现,当我们尝试传输这些文件时,我们必须先使用winrar对其进行压缩,但是这花费了太多时间! Also two hours to compress one parent folder. 还需要两个小时来压缩一个父文件夹。

In fact the images in the application are map images like the google map tiles: 实际上,应用程序中的图像是类似于Google地图图块的地图图像:

http://mt1.google.com/vt/lyrs=m@156067651&hl=zh-CN&x=27&y=48&z=7&s=G || || 在此处输入图片说明

So I wonder if there is an good idea to save/transfer these small but large amount files? 所以我想知道是否有一个好主意来保存/传输这些小而大量的文件?

Images like that are likely to already be compressed so you will get little gain in bandwidth use (and so transfer speed) from the compression step. 像这样的图像可能已经被压缩,因此从压缩步骤中获得的带宽使用(以及传输速度)收益很小。

If the compression process is taking along time where your CPU is busy then try instead just creating a plain tar file (which joins all the files into one archive without applying any compression). 如果压缩过程耗费了CPU的时间,请尝试创建一个简单的tar文件(将所有文件都合并到一个归档文件中,而不应用任何压缩)。 I don't know about winrar but most other compression tools (like 7zip) can generate a tar file, so I'm guessing winrar can too. 我不知道winrar,但是大多数其他压缩工具(如7zip)都可以生成tar文件,因此我猜想winrar也可以。

If you regularly transfer the whole set of files but only small numbers are added/changed each time, you might want to look into other transfer methods like rsync . 如果您定期传输整个文件集,但是每次仅添加/更改少量文件,则可能需要研究其他传输方法,例如rsync You don't describe either of your environments so I can't tell if this is likely to be available to you, but if it is rsync does an excellent job of only transferring changes (speeding up the transfer significantly) and it also always uses one connection so you don't get hit by the per file latency of FTP and other protocols - one file follows the previous one down the same connection as if the parts being transferred had been tar ed together so you don't need that extra step to pack the files at one and (and unpack them at the other). 您没有描述任何一种环境,所以我无法确定这是否可能适用于您,但是如果它是rsync,则它仅传输更改(显着加快了传输速度)就做得很好,并且它始终会使用一个连接,所以你不要被FTP等协议的每个文件的等待时间打-一个文件沿用了前一个上下一致的连接,就好像被转移的零件已经tar编在一起,这样你就不会需要一个额外的步骤将文件打包在一个文件中(并在另一个文件上解压缩)。

Those images are already compressed. 这些图像已经被压缩。 However, to increase transfer speed, you might try using rar in 'archive' mode. 但是,为了提高传输速度,您可以尝试在“存档”模式下使用rar。 This does the same thing as tar: concatenates all the files together into one big file. 这与tar的作用相同:将所有文件连接在一起成为一个大文件。 Don't use any compression in your archive format. 不要以存档格式使用任何压缩。

Maybe you can use a fast compression library like Snappy . 也许您可以使用像Snappy这样的快速压缩库。 However, it can only compress a single file, and you surely don't want to transfer each file separately. 但是,它只能压缩单个文件,并且您当然不希望分别传输每个文件。 I'd create an uncompressed TAR archive for that. 为此,我将创建一个未压缩的TAR存档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM