-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
68 lines (51 loc) · 1.72 KB
/
main.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import fs
import shutil
class GetFile:
def __init__(self):
self.getDir()
self.getFileExtension()
self.findDirInPath()
self.findFile()
self.getOutputPath()
def getDir(self):
print('Input directory')
path = input('>>>')
if(fs.isdir(path)):
self.path = path
else:
print('Please input a valid directory !')
exit()
def getFileExtension(self):
print('Input file extension name')
ext = input('>>>')
ext = ext.split(' ')
self.ext = ext
def findDirInPath(self):
path = [self.path]
dirs = fs.listdirs(path[0])
dirs = list(dirs)
path.extend(dirs)
self.path = path
def findFile(self):
path = self.path
print(path)
correctFile = []
for p in path:
print(p)
for extname in self.ext:
for filename in fs.find('*.'+extname, path=p):
correctFile.append(filename)
# correctFile.extend(self.findCorrectFile(files))
print('Find '+ str(len(correctFile))+' files with extension name ' + str(self.ext))
self.correctFile = correctFile
def getOutputPath(self):
print('Input output folder path')
self.output = input('>>>')
self.outputFiles()
def outputFiles(self):
for file in self.correctFile:
name = fs.basename(file)
shutil.copyfile(file,self.output+'/'+name)
#fs.rename(file,self.output+'/'+name)
print('finish')
gf = GetFile()