It's quite difficult to give you an answer that you'll just be able to take and use yourself but I can give you the concept and you can take it from there.
I created a basic flow that looks like this ...

All it does is open notepad, write in some text and save the file into c:\temp\test.csv ...!
There are a couple of intermediate steps for creating the file in question so that the flow works, etc. but that's nominal to the process.
In the flow itself, I have a UI Element which links to the main text area within notepad. In a later step, I want to select that textarea but between opening notepad and saving the file, the title of the window changes.
Before Save

After Save

If the name of my file changes, I need to be able to change the name of the window that I am wanting to select and that selection happens in the second last step where it is trying to focus on a text field in the given window.
If the selector isn't correct then that step will not be able to find the window and an error will be thrown.
The easiest way to do this is to anticipate what the name of the window is going to be and make the selection dynamic. So as an example, the UI Element selector for the window before the file is saved is this ...
:desktop > window[Name="Untitled - Notepad"][Process="notepad"]
... and after the save is this ...
:desktop > window[Name="test.csv - Notepad"][Process="notepad"]
You'll see that the way I have done this is to make the selector dynamic by passing in the name of a variable that stores the name of the file I am saving to.
The selector then looks like this ...
:desktop > window[Name="%FileName% - Notepad"][Process="notepad"]

So no matter what my file name is, the selector should always work because I have allowed for the name of the window to change.
As I said, that's a simple way to do it and shows you an example, you just need to adapt it to your scenario.