#!/usr/bin/env python
# -*- coding: cp936 -*-
import os
import time
def getDirAndCopyFile(sourcePath,targetPath):
if not os.path.exists(sourcePath):
return
if not os.path.exists(targetPath):
os.makedirs(targetPath)
#遍历文件夹
for fileName in os.listdir(sourcePath):
#拼接原文件或者文件夹的绝对路径
absourcePath = os.path.join(sourcePath, fileName)
#拼接目标文件或者文件加的绝对路径
abstargetPath = os.path.join(targetPath, fileName)
#判断原文件的绝对路径是目录还是文件
if os.path.isdir(absourcePath):
#是目录且目录不存在就创建相应的目标目录
if not os.path.exists(targetPath):
os.makedirs(abstargetPath)