import os
import shutil
path=r'F:/os' # 原文件夹路径,还有文件夹
all=os.listdir(path)
all_path=[]
for i in all:
all_path1=os.path.join('F:\os',i)
all_path.append(all_path1)
newpath = r'F:/all' # 目的文件夹路径
def listMyDir(param):
pass
def writeFile(param):
pass
for absolute_path in all_path:
for dirpath,dirnames,filenames in os.walk(absolute_path): #遍历目录
if dirnames:
for dirname in dirnames:
listMyDir(os.path.join(dirpath, dirname))
if filenames:
for filename in filenames:
writeFile(os.path.join(dirpath,filename))
file_name = '{0}/{1}'.format(dirpath, filename) #拼接形成文件路径
shutil.move(file_name, newpath) #批量移动文件到新文件夹
print('end')
python 移动文件,移动文件夹里的文件夹里的文件
最新推荐文章于 2024-09-05 10:28:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)