Created
February 7, 2013 20:46
-
-
Save ferryzhou/4734020 to your computer and use it in GitHub Desktop.
concatenate binary files with ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given a directory or a set of files | |
# concatenate the binary files | |
# output a single binary file | |
# usage: | |
# ruby concatenate_binary_files "/xxx/xx/*.bin" "/xxx/xx.bin" | |
infiles = ARGV[0] | |
outpath = ARGV[1] | |
File.open(outpath, 'wb') do |outfile| | |
Dir.glob(infiles).each do |file| | |
p file | |
outfile.write(File.open(file, 'rb').read) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment