-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanuplibrary
More file actions
executable file
·70 lines (54 loc) · 1.46 KB
/
cleanuplibrary
File metadata and controls
executable file
·70 lines (54 loc) · 1.46 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
#!/usr/bin/python
# Gianmarco Brocchi
'''
Search for file in a directory and
in all subforlders, filter file name
and copy, move or delete it.
Use ./cleanuplibrary dir
Remembere to check te copy or (re)move option!
'''
def dot(x):
# remember to import regular expression
strip = re.findall(r"\d+[.]\s", x)
if strip != []:
return x
else:
return 0
import os, sys, re
import shutil
try:
rootdir = sys.argv[1]
# print rootdir
except:
print "non hai inserito la cartella da cui partire"
sys.exit()
file_found = []
file_path = []
for root, subFolders, files in os.walk(rootdir):
# for folder in subFolders:
# print "%s has subdirectory %s" % (root, folder)
for filename in files:
filePath = os.path.join(root, filename)
# print filename + " path: %s \n" % filePath,
file_found.append(filename)
file_path.append(filePath)
# print file_path
# print "\nfiltrato:",
filtered_path = filter(dot, file_path)
# print filtered_path
print file_found
print "\nfiltro:",
filtered_file = filter(dot, file_found)
print filtered_file
# Remove file
# for i in filtered_path:
# print "Rimuovo %s" % i
# os.remove(i)
# Move file
# for i in filtered_path:
# print "Sposto %s in Scrivania/double track" % i
# shutil.move(i, "/home/gimmy/Scrivania/double\ track/")
# Copy file
for i in filtered_path:
print "Copio %s in Scrivania/double_track" % i
shutil.copy(i, "/home/gimmy/Scrivania/double_track/")