i´ve a problem with a script, working fine until last month and there is no idea coming up what to do. I use PyCharm 2017.3.7 for this script because every Version above 2018.3.3 do not work with QGIS
It is a complete easy basic script, loading and saving a python project as a batch function to handle bad layers. But now the script kills all layers of my project so i get an empty one back. Any ideas for solving the problem. Maybe another code....
from qgis.core import *
import os
QgsApplication.setPrefixPath(r"C:\OSGeo4W64\apps\qgis-ltr", True)
qgs = QgsApplication([], False)
qgs.initQgis()
ordner = r"C:\Users...."
for root,dirs, files in os.walk(ordner):
for file in files:
if "QGZ" in file.upper():
project = QgsProject.instance()
project.read(os.path.join(root,file))
QgsProject.instance().write()
qgs.exitQgis()