Skip to content

Instantly share code, notes, and snippets.

@7shi
Created August 28, 2024 20:23
Show Gist options
  • Save 7shi/6d70225ba3ea985c9870146cb79d95c4 to your computer and use it in GitHub Desktop.
Save 7shi/6d70225ba3ea985c9870146cb79d95c4 to your computer and use it in GitHub Desktop.
[py] XML Archiver for Claude
import sys, html
def wrap_files_in_xml(file_names):
print('<?xml version="1.0" encoding="UTF-8"?>')
print('<files>')
for file_name in file_names:
print(f'<file name="{file_name}">')
with open(file_name, 'r') as file:
print(html.escape(file.read().rstrip()))
print('</file>')
print('</files>')
if __name__ == '__main__':
if len(sys.argv) < 2:
print(f'Usage: python {sys.argv[0]} file1 [file2 ...]')
else:
wrap_files_in_xml(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment