我是 Python 新手,目前正在开发一个应用程序,可以根据文件夹名称将文件夹移动到特定目录。
我没有收到任何错误或警告,但应用程序不会移动文件夹。这是代码:
import os
import shutil
def shorting_algorithm():
file_list = []
directory = input("Give the directory you want to search.")
newdir = "D:\\Torrents\\Complete\\Udemy"
name = "'" + input("Give the name of the files you want to move.") + "'"
xlist = os.listdir(directory)
print(xlist)
print(name)
for files in xlist:
if name in files:
shutil.move(directory + files,newdir)
shorting_algorithm()
注意:我尝试删除 "'" +...+"'" 但它也不起作用。有任何想法吗?