Coding: Read XML-file in CPR-file

I’ve been using Cubase for about 5 Years so I have created over 500 projects. I want to reboot my Laptop. At some point I started to save the projectfiles in a completely different folder from where the projects are saved, so the projects should have the file-path of their projectfolders saved somewhere. I know how I could theoretically move the Folders and Projectfiles so that the Projectfiles find the ressources again, but I’m really annoyed of the structure of how it was saved in the first place (that’s on me ofc).
I’m trying to write a code that reads the File-path to the respective Projectfolder and changes it’s current name to the name of the respective Projectfile.

As far as I’ve found out, the paths to the projectfolder is saved in the XML-files, which somehow are in the CPR-files. For some reason the Pythonscript can not read the XML-file, so I wonder if it’s not a usual XML-File and how I can read it correctly.

My Laptop is kinda slowly decomposing so I really need to manage this before it completely breaks down.

Hi there and welcome to the forums!

How did you find this out? As far as I can tell, the cpr format is completely binary.

TBH it was just a hint chatgpt gave me… I’m pretty new to coding so I’m trying to gather as much information as possible. Do you know how to extract the file path of the project folder from the CPR-file?

You can’t, sorry.
Besides, I don’t think you’re asking the right question. Is there a “project folder path” stored in a Cubase project?
Cubase stores the path to audio files, as can be seen in the Audio Pool, in the project. Is that what you mean?
When a Cubase project is opened and it can’t find an audio file where it last was, you will be asked to provide the new location of said file.

well, the cubase project stores the relative path to an Audiofile. But this requires the project to “know” where the Project folder is. Normally it “knows” because the project is saved inside of the project folder, but in my case it isn’t, so there should be a project folder path stored in the project file.
or the relativ path to the Audiofiles which should include the path to the projectfolder right?

Projectfile is in C:/user/musik/projects
projectfolder is in C:/user/documents/cubase
audiofile is in C:/user/documents/cubase/projectfolder)

Maybe there is a way to extract the path to the Audiofile and in return also find the path to the projectfolder

Are you sure about that? You can add audio files from all kinds of paths to your Cubase project. They do not have to be stored under the project folder.

I don’t know about that either.

This is what I believe to be the default/standard folder structure of a Cubase project:

Are you sure about that? You can add audio files from all kinds of paths to your Cubase project. They do not have to be stored under the project folder.

ah well that changes a lot then. Do you know where the midi data is stored?

Projectfile is in C:/user/musik/projects
projectfolder is in C:/user/documents/cubase
audiofile is in C:/user/documents/cubase/projectfolder)

This is how a lot of the projectfolders are stored in my case. That’s exactly my problem, because I don’t know which projectfolders belong to which projectfiles. So when I move the files and the Projectfolders and I won’t know how to find the folders if the project itself can’t.

that’s why I want to somehow rename the projectfolders and for that I need to know which folders belong to which projects.

Ofc I also need to know where the other Data the project needs is stored.

You could create a new project file, whose project folder is NOT where the project file is located.
Path of .cpr <> project folder path
Then scan the .cpr file with an editor, search for the path name of the project folder.
That should give you the answer.
Whether you can edit it insode the .cpr file is a whole other question. Proceed at your own risk.

Thankyou for all the help! I managed to write a programm doing exactly what I wanted to do and it works!
I still don’t know if there actually is an XML-File in the CPR-File, but I wrote the programm so that it finds the word “GTree” in the CPR-File, ignoring any signs it can’t identify. I found out that the name of the Projectfolder and the corresponding Directory of it is always found just before the string “GTree”.
Since i know how cubase automatically calls the projectfolders I know how its String starts and ends, so I can look for this Scheme in the indixes befor “GTree”. Same for the Directory. I put both into a list and the list as a value in a dictionary with the filename as its key. After going through all files and saving Filename, Projectfoldername and Directory in the Dictionary the program then finds each corresponding projectfolder with the help of the dictionary and then renames it after the file. Now when I move projectfolder and File and it asks me where the projectfolder is, I can search for the filename and find the projectfolder.

I won’t be messing with the way cubase saves the project anymore :smiley:

Here’s the code for anyone whose interested, it’s python. If anyone ever tries to use it make sure the indentions are correct:

import glob
import os
projektdateien ={}
while True:
verzeichnis_pfad=str(input(“Verzeichnispfad zu dem umzubenennenden Ordner Bitte:”))
print(“bist du sicher, dass das 100% richtig ist??:”,verzeichnis_pfad)
feedback = input(“Wenn ja drücke j wenn nein drücke n…”)
if feedback.lower() == “n”:
print(“ok dingus, du wirst wieder an den Anfang geleitet!\n\n\n”)
elif feedback.lower() == “j”:

muster = “*.cpr”
for datei_pfad in glob.glob(os.path.join(verzeichnis_pfad,muster)):
with open(datei_pfad, “r”, errors=‘ignore’) as datei:
inhalt =
index_end = inhalt.find(“GTree”)
index_start = index_end-50
start_end= inhalt[index_start:index_end]
while “Unbenannt” not in start_end and wiederholungen<max_wiederholungen:
start_end= inhalt[index_start:index_end]
print(“index_start:”,index_start,“\n mit start_end inhalt:”,start_end,“\n----->unbenannt nicht enthalten”)
index = start_end.find(“Unbenannt”)
if index != -1:
print(“String gefunden in”,datei_pfad, “an Index in start_end:”, index)
Zeichen = “”
ordner_pfad = “”
ordner_pfad +=start_end[index_ordner_pfad_anfang:index_ordner_pfad_ende]
print(“ordner pfad:”,ordner_pfad)

  while len(Zeichen)<13 and index<len(inhalt) and ord(start_end[index])!=0 and start_end[index]!="\\":
   Zeichen += (start_end[index])
  print("Unbenannt nicht gefunden, Projektordner hat möglicherweise ein anderes Namensschema oder wurde schon umbenannt")

for i in projektdateien:
for i in projektdateien:
print(“neuer Ordnername:”,neuer_ordner_name)
print(“alter Ordnername:”,alter_ordner_name)
print(“Verzeichnis aus dem Dict:”,verzeichnis)
print(“alter Pfad:”,alter_pfad)
print(“neuer Pfad:”,neuer_pfad)
print(“ORDNER WURDE ZU”,neuer_ordner_name,“UMBENANNT!!!\n\n\n”)