Skip to content

Commit 55d2962

Browse files
author
Leonard Lin
committedJun 7, 2009
Quickie little script to move and automatically alphabetize incoming files (in this case, comics, but this works equally as well for any files)
1 parent 5d1751c commit 55d2962

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
 

‎alphabetize_incoming_comics.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/python
2+
3+
import os, re, shutil
4+
5+
destination_root = '/Volumes/Drobo/_incoming/_comics/_alpha/'
6+
path = os.getcwd()
7+
8+
for root, dirs, files in os.walk(os.getcwd()):
9+
for file in files:
10+
firstletter = file[0].upper()
11+
12+
# Numbers
13+
if re.search("[0-9]", firstletter):
14+
firstletter = "0-9"
15+
16+
source = os.path.join(root, file)
17+
destination = os.path.join(destination_root, firstletter, file)
18+
try:
19+
# print "MOVING", source, "TO", destination
20+
print " MOVE", file
21+
print " TO", os.path.join(destination_root, firstletter)
22+
shutil.move(source, destination)
23+
print " DONE"
24+
print
25+
except IOError:
26+
print "ERROR Couldn't move", source
27+
print " to", destination
28+
print

0 commit comments

Comments
 (0)