时间:2021-07-01 10:21:17 帮助过:18人阅读
代码如下:
# Filename: CopyFiles.py
import os
import os.path
folder_capacity = 20
def copy_files(src_dir, dest_dir):
count = 0
current_folder = ''
for item in os.listdir(src_dir):
abs_item = os.path.join(src_dir, item)
if os.path.isfile(abs_item):
count += 1
if count%folder_capacity == 1:
current_folder = os.path.join(dest_dir, str(count/folder_capacity))
os.mkdir(current_folder)
open(os.path.join(current_folder, item), 'wb').write(open(abs_item, 'rb').read())
copy_files(r'C:\\src', r'C:\\dest')