-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_directory_n_copy.py
More file actions
42 lines (36 loc) · 1 KB
/
search_directory_n_copy.py
File metadata and controls
42 lines (36 loc) · 1 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
#!/usr/bin/env python2
import os
import time
def directoryData(dir):
r = []
for root, dirs, files in os.walk(dir):
for name in files:
if '.' in name:
extn = name.split('.')
if extn[1] in ['Jpeg', 'jpeg']:
if '_' in name:
id = name.split('_')
r.append({
'file': name,
'id': id[0]
})
else:
r.append({
'file': name,
'id': extn[0]
})
return r
def copy(r):
sort = []
for i in r:
# sort.append(i['id'])
print(i['file'])
os.system('rsync /home/{} /tmp/'.format(i['file']))
return sort
if __name__ == '__main__':
path='/home/'
# path='/home/PDF/'
dict_data = directoryData(path)
# print(dict_data)
variab = copy(dict_data)
print(variab)