|
1 |
| -'''Python program to move file from one folder to another folder. |
| 1 | +"""Python program to move file from one folder to another folder. |
2 | 2 | @author : CodePerfectPLus
|
3 | 3 | @language : Python 3
|
4 | 4 | Website : http://codeperfectplus.github.io/
|
|
9 | 9 | / /___ / /_/ // /_/ // __/ / ____// __// / / __// __// /__ / /_ / ____// // /_/ /(__ )
|
10 | 10 | \____/ \____/ \__,_/ \___/ /_/ \___//_/ /_/ \___/ \___/ \__/ /_/ /_/ \__,_//____/
|
11 | 11 |
|
12 |
| -''' |
| 12 | +""" |
13 | 13 | import os
|
14 | 14 | from os import path
|
15 | 15 | from shutil import move
|
16 | 16 | import tkinter as tk
|
17 | 17 |
|
18 | 18 |
|
19 | 19 | def create_folder():
|
20 |
| - paths = ['Programing File', |
21 |
| - 'Compressed', |
22 |
| - 'Application', |
23 |
| - 'Picture', |
24 |
| - 'Video', |
25 |
| - 'Documents', |
26 |
| - 'Music', |
27 |
| - 'CodePerfectPlus'] |
| 20 | + paths = [ |
| 21 | + "Programing File", |
| 22 | + "Compressed", |
| 23 | + "Application", |
| 24 | + "Picture", |
| 25 | + "Video", |
| 26 | + "Documents", |
| 27 | + "Music", |
| 28 | + "CodePerfectPlus", |
| 29 | + ] |
28 | 30 | for root in paths:
|
29 |
| - try: |
30 |
| - os.mkdir(root) |
31 |
| - except OSError as error: |
32 |
| - print('Folder Already Exists') |
33 |
| -pic = ['.jpeg','.jpg','.png','.gif','.tiff','.raw'] |
34 |
| -pytho =['.ipynb','.java','.cs','.js'] |
35 |
| -txt = ['.txt','.pdf','.doc', '.pdf', '.ppt', '.pps', '.docx', '.pptx'] |
36 |
| -music = [ '.mp3', '.wav', '.wma', '.mpa', '.ram', '.ra', '.aac', '.aif', '.m4a', '.tsa'] |
37 |
| -zips = ['.zip', '.rar', '.arj', '.gz', '.sit', '.sitx', '.sea', '.ace', '.bz2', '.7z'] |
38 |
| -app = ['.exe','.msi'] |
39 |
| -vid = ['.mp4','.webm','.mkv','.MPG', '.MP2', '.MPEG', '.MPE', '.MPV', '.OGG', '.M4P', '.M4V', |
40 |
| - '.WMV', '.MOV', '.QT', '.FLV', '.SWF','.AVCHD','.avi', '.mpg', '.mpe', '.mpeg', '.asf', '.wmv', '.mov', '.qt', '.rm'] |
| 31 | + try: |
| 32 | + os.mkdir(root) |
| 33 | + except OSError as error: |
| 34 | + print("Folder Already Exists") |
| 35 | + |
| 36 | + |
| 37 | +pic = [".jpeg", ".jpg", ".png", ".gif", ".tiff", ".raw"] |
| 38 | +pytho = [".ipynb", ".java", ".cs", ".js"] |
| 39 | +txt = [".txt", ".pdf", ".doc", ".pdf", ".ppt", ".pps", ".docx", ".pptx"] |
| 40 | +music = [".mp3", ".wav", ".wma", ".mpa", ".ram", ".ra", ".aac", ".aif", ".m4a", ".tsa"] |
| 41 | +zips = [".zip", ".rar", ".arj", ".gz", ".sit", ".sitx", ".sea", ".ace", ".bz2", ".7z"] |
| 42 | +app = [".exe", ".msi"] |
| 43 | +vid = [ |
| 44 | + ".mp4", |
| 45 | + ".webm", |
| 46 | + ".mkv", |
| 47 | + ".MPG", |
| 48 | + ".MP2", |
| 49 | + ".MPEG", |
| 50 | + ".MPE", |
| 51 | + ".MPV", |
| 52 | + ".OGG", |
| 53 | + ".M4P", |
| 54 | + ".M4V", |
| 55 | + ".WMV", |
| 56 | + ".MOV", |
| 57 | + ".QT", |
| 58 | + ".FLV", |
| 59 | + ".SWF", |
| 60 | + ".AVCHD", |
| 61 | + ".avi", |
| 62 | + ".mpg", |
| 63 | + ".mpe", |
| 64 | + ".mpeg", |
| 65 | + ".asf", |
| 66 | + ".wmv", |
| 67 | + ".mov", |
| 68 | + ".qt", |
| 69 | + ".rm", |
| 70 | +] |
| 71 | + |
41 | 72 |
|
42 | 73 | def start():
|
43 | 74 | for f in os.listdir():
|
44 |
| - name , ex = path.splitext(f) |
| 75 | + name, ex = path.splitext(f) |
45 | 76 | for i in range(len(pic)):
|
46 | 77 | if ex == pic[i]:
|
47 |
| - move(f,'Picture') |
| 78 | + move(f, "Picture") |
48 | 79 | for i in range(len(vid)):
|
49 | 80 | if ex == vid[i]:
|
50 |
| - move(f,'Video') |
| 81 | + move(f, "Video") |
51 | 82 | for i in range(len(pytho)):
|
52 | 83 | if ex == pytho[i]:
|
53 |
| - move(f,'Programing File') |
| 84 | + move(f, "Programing File") |
54 | 85 | for i in range(len(txt)):
|
55 | 86 | if ex == txt[i]:
|
56 |
| - move(f,'Documents') |
| 87 | + move(f, "Documents") |
57 | 88 | for i in range(len(music)):
|
58 | 89 | if ex == music[i]:
|
59 |
| - move(f,'Music') |
| 90 | + move(f, "Music") |
60 | 91 | for i in range(len(app)):
|
61 | 92 | if ex == app[i]:
|
62 |
| - move(f,'Application') |
| 93 | + move(f, "Application") |
63 | 94 | for i in range(len(zips)):
|
64 | 95 | if ex == zips[i]:
|
65 |
| - move(f,'Compressed') |
| 96 | + move(f, "Compressed") |
66 | 97 |
|
67 | 98 |
|
68 |
| -# Gui |
69 |
| -effects=tk.GROOVE |
| 99 | +# Gui |
| 100 | +effects = tk.GROOVE |
70 | 101 |
|
71 | 102 | window = tk.Tk()
|
72 | 103 |
|
73 |
| -frame_a = tk.Frame(master=window,width=80,relief=effects,borderwidth=5) |
74 |
| -frame_b = tk.Frame(master=window,width=80,relief=effects,borderwidth=5) |
| 104 | +frame_a = tk.Frame(master=window, width=80, relief=effects, borderwidth=5) |
| 105 | +frame_b = tk.Frame(master=window, width=80, relief=effects, borderwidth=5) |
75 | 106 |
|
76 |
| -frame_a.grid(row =1, column=1) |
77 |
| -frame_b.grid(row=2,column=1) |
| 107 | +frame_a.grid(row=1, column=1) |
| 108 | +frame_b.grid(row=2, column=1) |
78 | 109 |
|
79 |
| -window.rowconfigure(2,minsize=300,weight=1) |
80 |
| -window.columnconfigure(1,minsize=300,weight=1) |
| 110 | +window.rowconfigure(2, minsize=300, weight=1) |
| 111 | +window.columnconfigure(1, minsize=300, weight=1) |
81 | 112 |
|
82 | 113 |
|
83 |
| -btn = tk.Button(master=frame_a,text='Create Folder',command=create_folder,bg='green',width=20,height=5) |
84 |
| -btn2 = tk.Button(master=frame_b,text='Move Now',command=start,bg='red',width=20,height=5) |
85 |
| -lbl = tk.Label(master=window,text='Warning \n First Create Folder Then Click On Move',fg='red',bg='black',width=50) |
| 114 | +btn = tk.Button( |
| 115 | + master=frame_a, |
| 116 | + text="Create Folder", |
| 117 | + command=create_folder, |
| 118 | + bg="green", |
| 119 | + width=20, |
| 120 | + height=5, |
| 121 | +) |
| 122 | +btn2 = tk.Button( |
| 123 | + master=frame_b, text="Move Now", command=start, bg="red", width=20, height=5 |
| 124 | +) |
| 125 | +lbl = tk.Label( |
| 126 | + master=window, |
| 127 | + text="Warning \n First Create Folder Then Click On Move", |
| 128 | + fg="red", |
| 129 | + bg="black", |
| 130 | + width=50, |
| 131 | +) |
86 | 132 |
|
87 |
| -lbl.grid(row=0,column=1) |
88 |
| -btn.grid(row=1,column=0) |
89 |
| -btn2.grid(row=1,column=1) |
| 133 | +lbl.grid(row=0, column=1) |
| 134 | +btn.grid(row=1, column=0) |
| 135 | +btn2.grid(row=1, column=1) |
90 | 136 | window.mainloop()
|
0 commit comments