# author by LYS 2017/5/24
# for Deep Learning course
'''
1. read the whole files under a certain folder
2. chose 10000 files randomly
3. copy them to another folder and save
'''
import os, random, shutil
def copyFile(fileDir,tarDir):
# 1
pathDir = os.listdir(fileDir)
# 2
sample = random.sample(pathDir, 10)
print sample
# 3
for name in sample:
shutil.copyfile(fileDir+name, tarDir+name)
if __name__ == '__main__':
fileDir = "C:\Users\Administrator\Desktop\AUTO"
tarDir = 'C:\Users\Administrator\Desktop\随机损伤照片/'
copyFile(fileDir,tarDir)
08-08
1014
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)