Added headers
This commit is contained in:
parent
d130fa5831
commit
e81d2c938b
57 changed files with 361 additions and 56 deletions
33
process_md_files.py
Normal file
33
process_md_files.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/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.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue