Fast and simple binary concatenate files in Powershell

前端 未结 4 1432
耶瑟儿~
耶瑟儿~ 2020-12-05 10:32

What\'s the best way of concatenating binary files using Powershell? I\'d prefer a one-liner that simple to remember and fast to execute.

The best I\'ve come up with

4条回答
  •  误落风尘
    2020-12-05 11:02

    The approach you're taking is the way I would do it in PowerShell. However you should use the -ReadCount parameter to improve perf. You can also take advantage of positional parameters to shorten this even further:

    gc File1.bin,File2.bin -Enc Byte -Read 512 | sc new.bin -Enc Byte
    

    Regarding the use of the -ReadCount parameter, I did a blog post on this a while ago that folks might find useful - Optimizing Performance of Get Content for Large Files.

提交回复
热议问题