Extracting file paths and adding them

See:

As a starting point, and then you can clarify exactly which parts you are having any further problems with.