Created
January 6, 2019 13:34
-
-
Save glamourzc/2d99cba564c1b0304e27c66567463e0f to your computer and use it in GitHub Desktop.
使用python遍历文件夹复制文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path | |
import shutil | |
finalPos = open("J:/SourcesDataSet/Pos.txt",'w') | |
for root,dirs,files in os.walk("J:/SourcesDataSet/"): | |
if 'Pos.txt' in files: | |
pos = open(root+'/Pos.txt','r') | |
temp = pos.readlines() | |
finalPos.writelines(temp) | |
pos.close() | |
for i in files: | |
if os.path.splitext(i)[1] == '.bmp': | |
shutil.copy(root+'/'+i,'J:/SourcesDataSet') | |
finalPos.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment