├── file.ico ├── file.png ├── README.md └── file_easy.py /file.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hardeepsingh980/File-Easy/master/file.ico -------------------------------------------------------------------------------- /file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hardeepsingh980/File-Easy/master/file.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # File-Easy 2 | This application is created by Hardeep Singh. This application helps in deleting the duplicated files in a selected directory. It can also sort the different types of files in different folders. 3 | -------------------------------------------------------------------------------- /file_easy.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import filedialog as fd 3 | from tkinter import messagebox as mb 4 | import os 5 | import shutil 6 | 7 | 8 | class File_easy: 9 | 10 | def sort_main(self): 11 | dir_ = fd.askdirectory(initialdir='D:\\',title='Select Directory') 12 | 13 | if dir_ == '': 14 | return True 15 | 16 | music_ex = ['mp3','wav'] 17 | video_ex = ['mp4','mkv'] 18 | doc_ex = ['py','txt'] 19 | exe_ex = ['exe'] 20 | img_ex = ['jpg','jpeg','png'] 21 | 22 | dir_files = os.listdir(dir_) 23 | 24 | for file in dir_files: 25 | exten = file.split('.')[-1] 26 | for ex in music_ex: 27 | if exten == ex: 28 | try: 29 | os.mkdir(f'{dir_}\\Music') 30 | except FileExistsError: 31 | pass 32 | 33 | src = dir_+'\\'+file 34 | 35 | shutil.move(src,f'{dir_}\\Music') 36 | 37 | for ex in video_ex: 38 | if exten == ex: 39 | try: 40 | os.mkdir(f'{dir_}\\Video') 41 | except FileExistsError: 42 | pass 43 | 44 | src = dir_+'\\'+file 45 | 46 | shutil.move(src,f'{dir_}\\Video') 47 | 48 | for ex in img_ex: 49 | if exten == ex: 50 | try: 51 | os.mkdir(f'{dir_}\\Images') 52 | except FileExistsError: 53 | pass 54 | 55 | src = dir_+'\\'+file 56 | 57 | shutil.move(src,f'{dir_}\\Images') 58 | 59 | for ex in doc_ex: 60 | if exten == ex: 61 | try: 62 | os.mkdir(f'{dir_}\\Documents') 63 | except FileExistsError: 64 | pass 65 | 66 | src = dir_+'\\'+file 67 | 68 | shutil.move(src,f'{dir_}\\Documents') 69 | 70 | for ex in exe_ex: 71 | if exten == ex: 72 | try: 73 | os.mkdir(f'{dir_}\\Exe_files') 74 | except FileExistsError: 75 | pass 76 | 77 | src = dir_+'\\'+file 78 | 79 | shutil.move(src,f'{dir_}\\Exe_files') 80 | 81 | 82 | 83 | message = mb.askquestion('Done','Sorting Process Is Complete.\n'+'Click The Yes Button To Check The Folder.') 84 | if message == 'yes': 85 | os.startfile(dir_) 86 | 87 | 88 | 89 | def del_dup(self): 90 | dir_ = fd.askdirectory(initialdir='D:\\',title='Select Directory') 91 | 92 | if dir_ == '': 93 | return True 94 | 95 | os.chdir('D:\\') 96 | 97 | files = [] 98 | 99 | files_2 = [] 100 | 101 | to_del = [] 102 | 103 | drive = dir_ 104 | 105 | main = os.listdir(f'{drive}\\') 106 | for i in main: 107 | 108 | try: 109 | sub = os.listdir(f'{drive}\\{i}') 110 | for j in sub: 111 | 112 | try: 113 | sub_2 = os.listdir(f'{drive}\\{i}\\{j}') 114 | for k in sub_2: 115 | 116 | try: 117 | sub_3 = os.listdir(f'{drive}\\{i}\\{j}\\{k}') 118 | for m in sub_3: 119 | 120 | try: 121 | sub_4 = os.listdir(f'{drive}\\{i}\\{j}\\{k}\\{m}') 122 | except: 123 | 124 | files.append(f'{drive}\\{i}\\{j}\\{k}\\{m}') 125 | pass 126 | except: 127 | 128 | files.append(f'{drive}\\{i}\\{j}\\{k}') 129 | pass 130 | 131 | except: 132 | 133 | files.append(f'{drive}\\{i}\\{j}') 134 | pass 135 | 136 | 137 | except: 138 | 139 | files.append(f'{drive}\\{i}') 140 | pass 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | for i in files: 149 | n = i.split('\\') 150 | new = n[-1] 151 | if new not in files_2: 152 | files_2.append(new) 153 | else: 154 | to_del.append(i) 155 | 156 | str_ = [] 157 | if len(to_del) != 0: 158 | for i in to_del: 159 | str_.append(i+'\n') 160 | 161 | message = mb.askquestion('Confirm', 'Duplicate Find At : \n\n'+''.join(str_)+'\nDo You Want To Delete All The Files.') 162 | 163 | if message == 'yes': 164 | for i in to_del: 165 | os.remove(i) 166 | mb.showinfo('Done', 'Duplicates Successfully Removed\n'+str(len(to_del))+' Files Were Removed.') 167 | 168 | else: 169 | mb.showinfo('Done','You Choosed No.\n0 Files Were Removed.') 170 | else: 171 | mb.showinfo('Done','Scan Complete.\n'+'No Duplicated Were Found In Selected Directory.') 172 | 173 | 174 | 175 | 176 | 177 | def home_func(self): 178 | header.configure(text='Welcome...',font=('Georgia',30)) 179 | header.place(x=180,y=80) 180 | caption1.configure(text='Select The Options\n At Left To Perform A Task.',font=('Georgia',20)) 181 | caption1.place(x=180,y=180) 182 | button.place(x=10000,y=1000) 183 | 184 | 185 | def delete_dup_func(self): 186 | header.configure(text='Delete Duplicate',font=('Georgia',20)) 187 | header.place(x=180,y=80) 188 | caption1.configure(text='Choose The Directory\n Where You Want To Search For Duplicates.',font=('georgia',12)) 189 | caption1.place(x=160,y=150) 190 | button.configure(text='Choose Directory',command=self.del_dup) 191 | button.place(x=180,y=250) 192 | 193 | def sort_func(self): 194 | header.configure(text='Sort',font=('Georgia',30)) 195 | header.place(x=180,y=80) 196 | caption1.configure(text='Choose The Directory\n Where You Want To Sort The Files.',font=('georgia',12)) 197 | caption1.place(x=160,y=150) 198 | button.configure(text='Choose Directory',command=self.sort_main) 199 | button.place(x=180,y=250) 200 | 201 | def help_func(self): 202 | header.configure(text='Help',font=('Georgia',30)) 203 | header.place(x=180,y=60) 204 | caption1.configure(text='This Application Have Two Features : \n\nDelete Duplicate : This Search For The Duplicate Files\n In Your PC And Help You To Clear Them.\n\nSort:This Helps You To Sort Your Different Types Of \n Files Into Different Folders. ',font=('georgia',12)) 205 | caption1.place(x=140,y=130) 206 | button.place(x=10000,y=1000) 207 | 208 | def about_func(self): 209 | header.configure(text='About',font=('Georgia',30)) 210 | header.place(x=180,y=80) 211 | caption1.configure(text='This Application Was Created By Hardeep Singh.\n He Created This For Personal Use But Later\n On A Demand This Was Published To Public.\n This Application Was Created Using Python.\n This Was One Of The Project Of Hardeep Singh.\nContact Us At: 9803588671',font=('georgia',12)) 212 | caption1.place(x=160,y=150) 213 | button.place(x=23000,y=25000) 214 | 215 | 216 | def __init__(self): 217 | win = Tk() 218 | win.geometry('550x310+250+200') 219 | win.title('File Easy') 220 | win.resizable(0,0) 221 | win.iconbitmap('file.ico') 222 | 223 | Label(win, text='File Easy',bg='green',fg='white',font=('arial black',26),width=30).pack() 224 | 225 | Label(win,bg='green',height=30,width=18).place(x=0,y=0) 226 | 227 | img = PhotoImage(file='file.png') 228 | 229 | Label(win,bg='red',height=7,width=10).place(x=450,y=0) 230 | 231 | Button(win,image=img,bg='red',bd=0,command=self.about_func).place(x=452,y=40) 232 | 233 | 234 | 235 | Button(win,bg='green',fg='white',text=' Home',font=('arial black',14),bd=0,command=self.home_func).place(x=10,y=60) 236 | 237 | Button(win,bg='green',fg='white',text='Delete\nDuplicates',font=('arial black',14),bd=0,command=self.delete_dup_func).place(x=0,y=100) 238 | 239 | Button(win,bg='green',fg='white',text='Sort Files',font=('arial black',14),bd=0,command=self.sort_func).place(x=0,y=180) 240 | 241 | Button(win,bg='green',fg='white',text=' Help',font=('arial black',14),bd=0,command=self.help_func).place(x=5,y=230) 242 | 243 | Button(win,bg='green',fg='white',text=' About',font=('arial black',14),command=self.about_func,bd=0).place(x=5,y=270) 244 | 245 | global copyright_ 246 | copyright_ = Label(win, bg='white',text='Copyright Belong\n To Hardeep Singh.',font=('Courier',8)).place(x=420,y=270) 247 | 248 | global header 249 | header = Label(win, text='Welcome...',font=('Georgia',30)) 250 | header.place(x=180,y=80) 251 | 252 | global caption1 253 | caption1 = Label(win, text='Select The Options\n At Left To Perform A Task.',font=('Georgia',20)) 254 | caption1.place(x=180,y=180) 255 | 256 | global button 257 | button = Button(win, text='',font=('Georgia',20),bd=0,bg='green',fg='white') 258 | 259 | win.mainloop() 260 | 261 | 262 | 263 | file_object = File_easy() 264 | --------------------------------------------------------------------------------