import os
from shutil import copy
获取目录下所有文件
def getAllFiles(targetDir):
files = []
listFiles = os.listdir(targetDir)
for i in range(0, len(listFiles)):
path = os.path.join(targetDir, listFiles[i])
if os.path.isdir(path):
files.extend(getAllFiles(path))
elif os.path.isfile(path):
files.append(path)
return files
if name == 'main':
pt = r'D:\myfile\music\周杰伦全专辑wav'
target = r'D:\myfile\music\周杰伦全专辑wav\全'
files = getAllFiles(pt)
for i in files:
copy(i, target)