-
Notifications
You must be signed in to change notification settings - Fork 0
/
tidyGUI.py
68 lines (61 loc) · 2.14 KB
/
tidyGUI.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import shutil
import Tkinter
from Tkinter import *
root = Tk()
root.title('tidy')
Label(text='Welcome to tidy').pack(side=TOP,padx=10,pady=10)
#entry = Entry(root, width=10)
#entry.pack(side=TOP,padx=10,pady=10)
src = "/Users/andre/Desktop"
stuffDir = src + "/MyStuff"
print "StuffDir Location: " + stuffDir
docsDir = stuffDir + "/Documents"
codeDir = stuffDir + "/Code"
picsDir = stuffDir + "/Pictures"
musicDir = stuffDir + "/Music"
vidsDir = stuffDir + "/Videos"
def createDirectoryStructure():
#create the directory structure if it does not exist already
print "Creating Directory Structure"
if not os.path.exists(stuffDir):
print "Creating Stuff directory"
os.makedirs(stuffDir)
if not os.path.exists(docsDir):
print "Created Documents Directory"
os.makedirs(docsDir)
if not os.path.exists(codeDir):
print "Created Code Directory"
os.makedirs(codeDir)
if not os.path.exists(picsDir):
print "Created Pictures Directory"
os.makedirs(picsDir)
if not os.path.exists(vidsDir):
print "Created Videos Directory"
os.makedirs(vidsDir)
if not os.path.exists(musicDir):
print "Created Music Directory"
os.makedirs(musicDir)
def moveFiles():
extension = "" #extension string, initialize to empty string
src_files = os.listdir(src)
filesMoved = 0
for file_name in src_files:
dest = stuffDir
full_file_name = os.path.join(src, file_name)
if (os.path.isfile(full_file_name)):
extension = file_name[file_name.find("."):]
if(extension == ".txt" or extension == ".docx" or extension == ".odt"):
dest = docsDir
elif(extension == ".java" or extension == ".c" or extension == ".h" or extension == ".py"):
dest = codeDir
elif(extension == ".jpg" or extension == ".png" or extension == ".raw"):
dest = picsDir
shutil.move(full_file_name, dest)
filesMoved = filesMoved + 1
print("File operations are now complete")
print(filesMoved),
print(" Files Moved")
Button(root, text='CreateDirectory', command=createDirectoryStructure).pack(side=LEFT)
Button(root, text='Clean!', command=moveFiles).pack(side=RIGHT)
root.mainloop()