-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileutilsApp.py
47 lines (40 loc) · 1.54 KB
/
FileutilsApp.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
from FileCollection import FileCollection
from FileController import FileController
if __name__ == '__main__':
import sys, getopt
directory = ''
extension = ''
function = 1
try:
opts, args = getopt.getopt(sys.argv[1:],"hdes",["directory=","extension="])
except getopt.GetoptError:
print 'Error: FileCollection.py -d directory -e *.png'
sys.exit(2)
print "options",opts
for opt, arg in opts:
print 'Option' + opt
if opt == '-h':
print 'Help: FileCollection.py --d directory --e *.png'
sys.exit()
elif opt in ("-d", "--directory"):
directory = arg
elif opt in ("-e", "--extension"):
extension = arg
elif opt in ("-s", "--split"):
print 'arg', arg, opt
directory = arg
function = 2
print 'Directory is "', directory
print "Begin searching repeated files"
if function == 1 :
fileCollection = FileCollection()
fileCollection.FindFiles(directory,extension)
# fileCollection.PrintFiles()
# sys.exit()
listOfRepeatedFiles = fileCollection.getFilesWithSameName()
print "List of Repeated Files ====="
fileCollection.PrintRepeatedFiles( listOfRepeatedFiles )
print "End of Repeated Files ====="
elif function == 2 :
fileController = FileController(FileCollection())
fileController.splitInFolder(directory)