Path 将所有.txt文件移动到特定文件夹

Path 将所有.txt文件移动到特定文件夹,path,operating-system,move,shutil,Path,Operating System,Move,Shutil,我想将当前文件夹和子文件夹中的所有.txt文件填充内容移动到名为“select”的文件夹中 我做了很多尝试,但我不能。。。 我的错在哪里? (我使用linux) 导入操作系统 path= os.getcwd() print ("The current working directory is %s" % path) selectpath = [] # r=root, d=directories, f = files for r, d, f in os.walk(path)

我想将当前文件夹和子文件夹中的所有.txt文件填充内容移动到名为“select”的文件夹中 我做了很多尝试,但我不能。。。 我的错在哪里? (我使用linux)
导入操作系统

path= os.getcwd()
print ("The current working directory is %s" % path)


selectpath = []
# r=root, d=directories, f = files
for r, d, f in os.walk(path):
    for file in d:
        if 'select' in file:
            selectpath.append(os.path.join(r, file))


print(selectpath)  
###################################################################

########################################################################

path= os.getcwd()

for r, d, f in os.walk(path):
    for file in f:
        if '.txt' in file:
         
            import shutil, os
            #files = ['file1.txt', 'file2.txt', 'file3.txt']

            xx=str(os.path.join(r, file))
            shutil.move(xx, str(selectpath))
           
            print(os.path.join(r, file))`