Skip to content

Commit 9efb59a

Browse files
author
wAOndering
committedJul 28, 2021
update fileComp
1 parent 028bdf0 commit 9efb59a

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed
 

‎fileCheck.py

+28-13
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,47 @@
44
import numpy as np
55

66

7-
8-
97
def commonElement(list1, list2, option='dext'):
108
'''
119
function to identify common element in the list
1210
option: 'dext' enables to look at the basefilename without the extension useful to check if the files
1311
were in deed compressed
1412
'''
13+
if len(list1)<len(list2):
14+
tmp = list1
15+
list1 = list2
16+
list2 = list1
17+
18+
list1Name = os.path.dirname(list1[0])
19+
list2Name = os.path.dirname(list2[0])
20+
1521
if option == 'dext':
16-
list1 = [x.split(os.sep)[-1].split('.')[0] for x in list1]
17-
list2 = [x.split(os.sep)[-1].split('.')[0] for x in list1]
22+
# modification takes care of multi period in the path
23+
list1 = [('.').join(x.split(os.sep)[-1].split('.')[:-1]) for x in list1]
24+
list2 = [('.').join(x.split(os.sep)[-1].split('.')[:-1]) for x in list2]
25+
# list1 = [x.split(os.sep)[-1].split('.')[0] for x in list1]
26+
# list2 = [x.split(os.sep)[-1].split('.')[0] for x in list2]
1827

1928
commonElem = [x for x in list1 if x in list2]
2029

2130
print('There are', len(commonElem), 'out of', max(len(list1), len(list2)), 'files which are common')
31+
print('For', list1Name, ':')
32+
print(len(commonElem), 'out of', len(list1), 'files which are common')
33+
print('For', list2Name, ':')
34+
print(len(commonElem), 'out of', len(list2), 'files which are common')
35+
36+
notcommonElem = [x for x in list2 if x not in list1]
37+
# alternatively could use np.setdiff1d(list1, list2)
38+
print('None common elements present in', list2Name, ' : ')
39+
print(notcommonElem)
40+
41+
42+
## toDel = [os.remove(''.join([list2Name,os.sep,x,'.avi'])) for x in commonElem]
43+
44+
45+
# return notcommonElem
2246

23-
notcommonElem = []
24-
if max(len(list1), len(list2)) != len(commonElem):
25-
notcommonElem = [x for x in list1 if x not in list2]
26-
# alternatively could use np.setdiff1d(list1, list2)
27-
print('None common element are:')
28-
print(notcommonElem)
29-
else:
30-
print('No none common element found')
3147

32-
return notcommonElem
3348

3449

3550
def getSize(filesList):

0 commit comments

Comments
 (0)
Please sign in to comment.