Answers for "how to iterate list and move files in the list to a folder in python"

17

iterate through all files in directory python

import os
directory = 'the/directory/you/want/to/use'

for filename in os.listdir(directory):
    if filename.endswith(".txt"):
      #do smth
      continue
    else:
    continue
Posted by: Guest on March-30-2020
1

how to get all folders on path in python

os.walk(directory)
[x[0] for x in os.walk(directory)]
Posted by: Guest on February-10-2020

Code answers related to "how to iterate list and move files in the list to a folder in python"

Python Answers by Framework

Browse Popular Code Answers by Language