Python get full path for files in folder passed as argument
<p>My goal is to be able to parse through a folder containing multiples images and get the absolute path for them so I can load them into OpenCV.</p>

<p>A single folder is passed in containing an unknown number of images. </p>

<pre><code>#FilePass.py

import os
import cv2
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("-1", "--first", required=True)
args = vars(ap.parse_args())
imagesToStitch = os.listdir(args["first"])
for image in imagesToStitch:
    print os.path.abspath(image)
</code></pre>

<p>This is the command to execute with the file path to the folder being used. </p>

<pre><code># python FilePass.py --first C:\Users\cradford\Documents\Research\ImagesToPass\Pass1
</code></pre>

<p>The images contained are and their corresponding full file path are:</p>

<pre><code>_001.jpg # "C:\Users\cradford\Documents\Research\ImagesToPass\Pass1"
_002.jpg # "C:\Users\cradford\Documents\Research\ImagesToPass\Pass1"
</code></pre>

<p>Desired output:</p>

<pre><code>C:\Users\cradford\Documents\Research\ImagesToPass\Pass1\_001.jpg
C:\Users\cradford\Documents\Research\ImagesToPass\Pass1\_002.jpg
</code></pre>

<p>Output with code used:</p>

<pre><code>C:\Users\cradford\Documents\Research\OpenCV Practice Files\_001.jpg
C:\Users\cradford\Documents\Research\OpenCV Practice Files\_002.jpg
</code></pre>

<p>I am pretty sure the discrepancy where the result reads "OpenCV Practice Files" is because it is looking at the abs.path of "image" in my for loop and the code file is saved in "OpenCV Practice Files".
Any help is appreciated. </p>