Added replacement of head tag again

This commit is contained in:
kaltokri
2023-10-20 22:45:52 +02:00
parent df6d968ebe
commit 038b89776d
3 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# import required module
from pathlib import Path
import os
# assign directory
directory = '.'
print( "Replacing head tag in all html files" )
# Read template file
with open( os.path.dirname(__file__) + '/docs-header.html', 'r') as file:
newhead = file.read()
# iterate over files in
# that directory
files = Path(directory).glob('*.html')
for file in files:
# print(file)
with open(file, 'r') as fileread:
filedata = fileread.read()
# Replace the target string
filedata = filedata.replace( '<head>', newhead )
# Write the file out again
with open(file, 'w') as filewrite:
filewrite.write(filedata)