Skip to content

Instantly share code, notes, and snippets.

@msymt
Created October 24, 2022 03:39
Show Gist options
  • Save msymt/69923a74a66c012e9595a7221ef3c596 to your computer and use it in GitHub Desktop.
Save msymt/69923a74a66c012e9595a7221ef3c596 to your computer and use it in GitHub Desktop.
xxd対象のファイル名とその結果を順に表示するプログラム
import glob
import subprocess
dir = "/path/to/dir"
files = glob.glob(dir + "*")
files.sort()
for file in files:
r = subprocess.run(["xxd", file], stdout=subprocess.PIPE)
with open("output.txt", "a") as f:
f.write(file + "\n")
f.write(r.stdout.decode("utf-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment