Delete the final part of each url from a list retrieved with SELECT

Thanks for your help, I really appreciate it.
From what you tell me I should therefore decide what the maximum number of photos will be and then repeat the instruction as many times.
I’m going to do some tests