连接大量二进制文件 [英] Concatenate large number of binary files
问题描述
我有大量(〜1800)小(〜2-6Kb)文件,希望将它们合并为一个大文件.
我尝试使用Get-Content
和Add-Content
使用PowerShell脚本,但这太慢了.有谁知道使用PowerShell脚本,其他一些系统命令或小型应用程序来执行此操作的相对快速的方法吗?
我不想下载并安装一些膨胀软件只是为了执行此简单操作,但是一个独立的可执行文件就可以了.我想自己可以自己整理一个小的C ++应用程序,但我不知道这样会不会更快.
那么,有什么建议吗?
(我应该提一下,我确实在Get-Content
上使用了-ReadCount
标志,以增加输入缓冲区,但这似乎无济于事.而且,当然,-Encoding
设置为
I have a large number (~1800) of small (~2-6Kb) files that i wish to concatenate into one large file.
I tried using a PowerShell script using Get-Content
and Add-Content
, but that was agonisingly slow. Does anyone know of a relatively fast way of doing this using either a PowerShell script, some other system commands, or a small application?
I don''t want to download and install some bloat-ware just to do this simple operation, but a single stand-alone executable would be fine. I guess i could whack together a small C++ application myself, but i don''t know if that would be any faster.
So, any suggestions?
( I should mention that i did use the -ReadCount
flag on Get-Content
, to increase the input buffer, but that didn''t seem to help. And, of course, the -Encoding
was set to byte
. So i''m not sure if the bottle-neck is I/O or something PowerShell is doing internally.)
推荐答案
复制命令的通配符形式?
What''s wrong with the wildcard form of copy command?
copy /b sourcesdir\*.* destfile
或类似的内容
注释:与查找,打开,关闭文件等相比,文件的实际复制无济于事.这解释了为什么通配符是最大的提速方法.也不用写一行代码! :)
干杯,
彼得
or something very similar
Comment: The actual copying of the files is nothing compared to finding, opening, closing them, etc. That explains why wildcards is the big speedup. Not a line of code to write, either! :)
Cheers,
Peter
这篇关于连接大量二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!