Last active
April 17, 2020 10:51
-
-
Save aluzed/92f51f5c1239d5f09eb1d59bb029fb30 to your computer and use it in GitHub Desktop.
Python file merger
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
import sys, hashlib, argparse | |
parser = argparse.ArgumentParser(description='Merge files.') | |
parser.add_argument('files', type=argparse.FileType('r'), nargs='+') | |
args = parser.parse_args() | |
output_file = "output" | |
def concat(files): | |
with open(output_file, "ab") as out1: | |
for f in files: | |
with open(f.name, "rb") as fp: | |
out1.write(fp.read()) | |
fp.close() | |
out1.close | |
print("merged into : " + output_file) | |
with open(output_file, "rb") as f: | |
md5 = hashlib.md5(f.read()).hexdigest() | |
print("MD5 : " + md5) | |
concat(args.files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment