33 lines
No EOL
952 B
Python
33 lines
No EOL
952 B
Python
#!/usr/bin/env python3
|
|
import os
|
|
import glob
|
|
|
|
# Directory containing the .md files
|
|
directory = 'Corpus/Standards/ISO27x/PECB-Lead-Auditor-Training/transcriptions'
|
|
|
|
# Find all .md files in the directory
|
|
md_files = glob.glob(os.path.join(directory, '*.md'))
|
|
|
|
for file_path in md_files:
|
|
# Get the filename without extension
|
|
filename = os.path.basename(file_path)
|
|
name_without_ext = os.path.splitext(filename)[0]
|
|
|
|
# Replace dashes with spaces
|
|
header_text = name_without_ext.replace('-', ' ')
|
|
|
|
# Create the header block
|
|
header = f'# {header_text}\n\n## Abstract\n\n## Transcription\n\n'
|
|
|
|
# Read the existing content
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Prepend the header
|
|
new_content = header + content
|
|
|
|
# Write back to the file
|
|
with open(file_path, 'w', encoding='utf-8') as f:
|
|
f.write(new_content)
|
|
|
|
print("Processed all .md files.") |