Choosing images randomly and presenting them again in the next block

OS** Win10 pro:
PsychoPy version 2023.1.2:

What are you trying to achieve?:

Hello,
I am trying to build an experiment with two parts (this an old-new task). In the first part (old images) I have 4 blocks, for each block I have an excel list with 40 images and I want only one randomly chosen image to be displayed. In the second part (old and new images with response) I want to have the same images that were randomly chosen to be presented again and an additional set of images (again randomly chosen from a list) to be displayed. in addition, all these images together need to be in a random order and to have their names written to the output data file.

What did you try to make it work?:
for the first part I think I have managed to make it randomly chose images and for the second part I have tried to use the idea used in the conditional_images_demo to make it present the previously chosen images.
I have tried a few ways to make it work since it did not display all the images that were presented in the first part or it presents each image twice. In addition the names of the images were not written in the output file.

Any help would be much appreciated.
Thanks!!