The fact that it deletes the comments when opened is actually a good thing.
Using that knowledge to your advantage.
Create a new Plugin
Project > ProjectSettings > Plugins Tab > Create
In your plugin.gd add
tool
extends EditorPlugin
var copyright = """; SPDX-FileCopyrightText: 2016, 2018-2019 Jane Doe <[email protected]>
; SPDX-FileCopyrightText: 2019 Example Company
;
; SPDX-License-Identifier: GPL-3.0-or-later
"""
func save_external_data():
#opens project file and append contents to copyright
var project_file = File.new()
project_file.open("res://project.godot", File.READ)
var license = copyright + project_file.get_as_text()
project_file.close()
#write contents of copyright to project.godot
project_file.open("res://project.godot", File.WRITE)
project_file.store_string(license)
project_file.close()
This way every time you close or save the project the copyright information gets added and since Godot cleans up the file on re-open it can be used again in this same way
Edit: forgot to mention Godot will throw a fit if you don't use ;
in project.godot to comment the lines so change your # Comment Line
to ; Comment Line