-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectoryFileExtension-3.py
50 lines (36 loc) · 1.3 KB
/
DirectoryFileExtension-3.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
from sys import *
import os
def DirectoryGetFileExtension(path , extension):
flag = os.path.isabs(path)
if(flag == False):
path = os.path.abspath(path)
exists = os.path.isdir(path)
if exists:
for dirname , subdir , filename in os.walk(path):
print("Current Folder is : ",dirname)
for file in filename:
if(file .lower().endswith(extension)):
print(file)
print(" ")
else:
print("Invalid Path")
def main():
print("Marvellous Infosystems by Sidheshwar Jawale")
print("Application Name : "+argv[0])
if(len(argv)!=3):
print("ERROR : INSUFFICIENT ARGUMENTS")
exit()
if(argv[1]=='-u') or (argv[1] == '-U'):
print("USAGE : ApplicationName AbsolutePath_of_Directory Extension")
exit()
if(argv[1] == "-h" ) or (argv[1] == '-H'):
print("HELP :The script is used to traverse specific directory and display all files which have given Extension ")
exit()
try:
DirectoryGetFileExtension(argv[1],argv[2])
except ValueError:
print("Error : Invalid Datatype of input")
except Exception :
print("Error : invalid input")
if __name__ == '__main__':
main()