-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileManagement.py
More file actions
80 lines (67 loc) · 2.39 KB
/
FileManagement.py
File metadata and controls
80 lines (67 loc) · 2.39 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
import os
class FileManagement:
path = []
folderQueue = []
def __init__(self, p):
self.folderQueue.append(p)
while len(self.folderQueue) != 0:
folder = self.folderQueue.pop()
for fileOrDirectory in os.listdir(folder):
f = os.path.join(folder, fileOrDirectory)
if os.path.isdir(f):
self.folderQueue.append(f)
else:
self.path.append(f)
def getPathList(self):
return self.path
def getPDFList(self):
PDFList = []
for i in range(len(self.path)):
if self.path[i].endswith(".pdf"):
PDFList.append(self.path[i])
return PDFList
def getDOCXList(self):
DOCXList = []
for i in range(len(self.path)):
if self.path[i].endswith(".docx"):
DOCXList.append(self.path[i])
return DOCXList
def getIMGList(self):
IMGList = []
suffixes = (".png", ".jpg", ".jpeg", ".bmp", ".eps", ".raw", ".cr2", ".nef", ".orf", ".sr2")
for i in range(len(self.path)):
if self.path[i].endswith(suffixes):
IMGList.append(self.path[i])
return IMGList
def getTXTList(self):
TXTList = []
for i in range(len(self.path)):
if self.path[i].endswith(".txt"):
TXTList.append(self.path[i])
return TXTList
def getVIDEOList(self):
VIDEOList = []
suffixes = (".mp4", ".mov", ".wmv", ".avi", ".webm", ".avi", ".flv", ".mkv", ".mpeg4", ".gif")
for i in range(len(self.path)):
if self.path[i].endswith(suffixes):
VIDEOList.append(self.path[i])
return VIDEOList
def getCSVList(self):
CSVList = []
for i in range(len(self.path)):
if self.path[i].endswith(".csv"):
CSVList.append(self.path[i])
return CSVList
def getXlSXList(self):
XlSXList = []
for i in range(len(self.path)):
if self.path[i].endswith(".xlsx"):
XlSXList.append(self.path[i])
return XlSXList
if __name__ == '__main__':
pathOfBackupFolder = input("Enter the path of the directory that has to be backed up")
obj = FileManagement(pathOfBackupFolder)
PDFpath = []
PDFpath = obj.getPDFList()
for i in range(len(PDFpath)):
print(PDFpath[i])