-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulticopy.py
47 lines (39 loc) · 1.27 KB
/
multicopy.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
#!/usr/bin/python3/
import shutil, os, sys, re
copyFrom = sys.argv[1]
dest = sys.argv[2]
print('How many series are we moving?')
numSeries = int(input(": "))
movedCount = 0
for i in range(numSeries):
whichSeries= input('Give a word from the file name:')
wslower = whichSeries.lower()
searchF = re.compile(wslower)
print ('Does %s series need a new folder? Y/n' % whichSeries)
seriesF = input(': ')
seriesf = seriesF.lower()
if seriesf == 'y':
print ('What would you like to name your folder?')
folderName = input(': ')
os.makedirs(os.path.join(dest, folderName))
print ('Folder created for %s.' % folderName)
elif seriesf == 'n':
print('Ok. We wont create a folder for %s.' % whichSeries)
print('Which folder would you like me to move it to?')
folderName = input(': ')
else:
pass
for f in os.listdir(copyFrom):
if os.path.isdir(os.path.join(copyFrom, f)) == False:
try:
fLow = f.lower()
match = searchF.findall(fLow)
if len(match) > 0:
shutil.move(os.path.join(copyFrom, f), os.path.join(dest, folderName))
#os.path.unlink(os.path.join(copyFrom, f))
movedCount += 1
except OSError:
print('Unable to move %s.' % match )
else:
pass
print ('Moved %d files.' % movedCount)