-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopy_files_csv.py
More file actions
37 lines (30 loc) · 856 Bytes
/
copy_files_csv.py
File metadata and controls
37 lines (30 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
批量复制文件并改名
@author: ChenXing
@email: onechenxing@163.com
@date: 2015/4/2
"""
import os
import os.path as path
import shutil as sh
sourceDir = "csv"
targetDir = "../../Assets/Resources/Configs/Csv/cn"
#要查找的文件后缀
suffixList = [".csv"]
#要添加的新后缀
addSuffix = ""
def checkSuffix(fileName):
for suffix in suffixList:
if fileName.endswith(suffix):
return True
return False
try:
for file in os.listdir(sourceDir):
sourceFile = path.join(sourceDir, file)
targetFile = path.join(targetDir, file + addSuffix)
if path.isfile(sourceFile) and checkSuffix(sourceFile):
sh.copy(sourceFile,targetFile)
except IOError:
print("copy file error")
print("copy_files_csv ok.")
#input()