python脚本 实现
import shutil
import os
def all_path(dirname,new_path):
result = []
file_names = []
for maindir, subdir, file_name_list in os.walk(dirname):
print("1: ",maindir)
print("2: ", subdir)
print("3: ",file_name_list[0])
print(len(file_name_list))
for i in range(len(file_name_list)):
if (i+1)%3 == 0:
file_names.append(file_name_list[i])
for filename in file_names:
apath = os.path.join(maindir, filename)
shutil.copy(apath,new_path)
result.append(apath)
print(result)
if __name__=='__main__':
new_path = r'./data4'
file_path = r'./x'
all_path(file_path,new_path)