Windows命令分割二进制文件
我想将二进制文件分割成更小的块。有人知道 Windows 命令吗?
由于 Android 的 UNCOMPRESS_DATA_MAX 约束,我无法使用 1MB 或更大的文件覆盖数据库。因此,如果有更好的方法,我也同意。
I would like to split a binary file into smaller chunks. Anyone knows a Windows command for that?
Because of Android's UNCOMPRESS_DATA_MAX constraint, I cannot overwrite the Database with a file 1MB or larger. So if there is a better way to do it I am OK with that too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
方法1:
makecab
可以将二进制文件以其自己的格式分割成更小的编码块,但它们不能被视为只是原始字节,类似于平面二进制文件例如。通过copy
加入,即。如果您正在考虑通过 CMD 编辑二进制文件,例如文件修补。不过,如果您只是想分割一个文件,然后在不进行编辑的情况下合并成一个文件,那么这些块可以通过extrac32
连接起来。例如。要使用
makecab
分割二进制文件,然后使用extrac32
连接,首先创建一个 ddf(文本)文件:然后:
要取回原始文件,请确保所有块都在同一个文件中目录:
MakeCAB 引入了文件夹的概念来引用连续的压缩字节集。
“MakeCAB 获取正在压缩的产品或应用程序中的所有文件,将字节作为一个连续的字节流,压缩整个流,将其切成适当的文件夹,然后用文件夹填充一个或多个文件柜。 ”
方法2:
对于原始字节块,powershell 可以拆分文件:
方法 3: 通过 certutil & CMD:
注释:
copy /b
连接请参阅下面的示例输出:
方法 2 & 3 然后可以通过
copy
加入在 Win 10 上测试
Method 1:
makecab
can split a binary file into smaller encoded chunks in it's own format, but they can't be treated as just raw bytes, similar to a flat binary file eg. to join viacopy
ie. in case you were looking at editing a binary file via CMD, eg. file patching. The chunks, however can then be joined byextrac32
, in case you were just looking at splitting a file and then joining into one piece later, without editing.eg. To split binary file with
makecab
then join withextrac32
, first make a ddf (text) file:Then:
To get the original file back, ensure all chunks are in the same directory:
MakeCAB introduces the concept of a folder to refer to a contiguous set of compressed bytes.
"MakeCAB takes all of the files in the product or application being compressed, lays the bytes down as one continuous byte stream, compresses the entire stream, chopping it up into folders as appropriate, and then fills up one or more cabinets with the folders."
Method 2:
For raw byte chunks, powershell can split files:
Method 3: via certutil & CMD:
Notes:
copy /b
See example output below:
Methods 2 & 3 can then be joined by
copy
Tested on Win 10
没有内置的 DOS 命令可以实现此目的。使用 unix split 命令的 dos 端口:
有第 3 方替代方案,但这是最简单的。
There's no built-in DOS command for that. Use the dos port of the unix split command:
There are 3rd party alternatives, but this is the simplest.
您还可以从 http://gnuwin32.sourceforge.net 安装 GnuWin
对于我的工作,我需要提取一些来自大型 Oracle 导出文件
DataBase.bak
的行。该文件是一个二进制文件,由文本行和二进制行混合而成。
要提取 2 个特定行之间的所有行,我只需输入以下命令
第一个命令将从 0 到 4114807 的所有行提取到
from.A
文件中,并将从 4114808 到 2*4114807 的所有行提取到来自.B
文件。我在
Notepad++
中加载Database.Bak
文件时发现FROM行号(= 4114807)。注意:Notepad++中显示的行号不等于
参数,因为 Notepad++ 行号是由split
命令中使用 lLF
和CR
字符生成的!我使用第二个命令将 from.B 文件中包含的所有前 10357 行提取到
to.A
文件中。要终止,我将
to.A
文件复制到包含所需提取的新Database.RANGE.bak
文件中。工作完成后,我从当前目录中删除所有 from.* 和 to.* 文件。
You can also install GnuWin from http://gnuwin32.sourceforge.net
For my work, I need to extract some lines from a big Oracle export's file
DataBase.bak
.This file is a binary file that is a mix of text's lines and binary lines.
To extract all lines between 2 specifics lines, I only enter following to command
The first command extract all lines from 0 to 4114807 into
from.A
file and all lines from 4114808 to 2*4114807 intofrom.B
file.I found FROM line's number (= 4114807) in loading
Database.Bak
file inNotepad++
.Caution: the line's number displayed in Notepad++ is not equal to
l
parameter used insplit
command because Notepad++ line's number are generated byLF
and alsoCR
characters !I use the second command to extract all first 10357 lines contains in from.B file into
to.A
file.To terminate, I copy
to.A
file into a newDatabase.RANGE.bak
file that contains needed extraction.When job is done, I delete all from.* and to.* files from current directory.