Save files in different folders


hello, i had a folder which contain 60 invoices, i want to open each pdf search for “image” inside each doc and then save the pdf in another folder relative to each “image”

how can i do that? and how can i use a table that make relation between “image” and folders.