title: how to list the images paths in the directory in python?
body: <p>I created one folder called dataset, then in this folder i created subfolder called subfold1, subfold2</p>
  <p><code>names=[]</code></p>
  <pre><code>for users in os.listdir(&quot;dataset&quot;):
      names.append(users)
  
  print(names)
  </code></pre>
  <p>Output:
  <code>['subfold1','subfold2']</code></p>
  <p>In the subfold1 , i have 5 images and subfold2 also i have 5 images</p>
  <p>Then, i want to list the images paths which i have inside the subfold1 and subfol2?</p>
  <pre><code>path= []
  for name in names:
      for image in os.listdir(&quot;dataset/{}&quot;.format(name)):
          path_string = os.path.join(&quot;dataset/{}&quot;.format(name), image)
          path.append(path_string)
  
  print(path)
  </code></pre>
  <p>My output is</p>
  <pre><code>['dataset/subfold1\\1_1.jpg', 'dataset/subfold1\\1_2.jpg', 'dataset/subfold1\\1_3.jpg', 'dataset/subfold1\\1_4.jpg', 'dataset/subfold1\\1_5.jpg', 'dataset/subfold2\\2_1.jpg', 'dataset/subfold3\\2_2.jpg', 'dataset/subfold2\\2_3.jpg', 'dataset/subfold2\\2_4.jpg', 'dataset/subfold2\\2_5.jpg']
  
  </code></pre>
  <p>I want the correct paths</p>