Код: Выделить всё
import os, shutil
fileList = []
for root, dirs, files in os.walk(r'K:\Users\User1\Desktop\Python\New folder'):
for file in files:
if file.endswith('.txt'):
fileList.append(file)
print fileList
source = "K:\\Users\\User1\\Desktop\\Python\\New folder"
destination = "K:\\Users\\User1\\Desktop\\Python\\New folder (2)"
for root, dirs, files in os.walk(r'K:\Users\User1\Desktop\Python\New folder'):
for file in files:
if fname in fileList:
shutil.move(source, destination)
Подробнее здесь: https://stackoverflow.com/questions/237 ... me-in-list
Мобильная версия