Apr-13-2019, 07:47 AM
(This post was last modified: Apr-13-2019, 08:00 AM by francisco_neves2020.)
(Apr-13-2019, 07:00 AM)wuf Wrote: Hi francisco PermissionError:!!! wuf :-)Hi Wuf, i got another way for it to work. I converted once the code that searches for the files (png, doc, docx, ...) to exe, i just need to place it in the folders i want and then from the main program a function to call all the exes in those specific folders. Yah, it gives a bit of work, indicating each path to the main program. I just put one of exes in the folder images, another downloads, documents, and so on, i hide the file from the user and then i press a button and it will organize all.
**code that organizes all files**(must be converted to exe once and placed in the folders that you want)
import os import sys from pathlib import Path DIRECTORIES = { "HTML": [".html5", ".html", ".htm", ".xhtml"], "IMAGENS": [".jpeg", ".jpg", ".tiff", ".gif", ".bmp", ".png", ".bpg", "svg", ".heif", ".psd"], "VIDEOS": [".avi", ".flv", ".wmv", ".mov", ".mp4", ".webm", ".vob", ".mng", ".qt", ".mpg", ".mpeg", ".3gp"], "DOCUMENTOS": [".pdf", ".oxps", ".epub", ".pages", ".docx", ".doc", ".fdf", ".ods", ".odt", ".pwi", ".xsn", ".xps", ".dotx", ".docm", ".dox", ".rvg", ".rtf", ".rtfd", ".wpd", ".xls", ".xlsx", ".ppt", "pptx", ".txt", ".in", ".out"], "ARQUIVOS": [".a", ".ar", ".cpio", ".iso", ".tar", ".gz", ".rz", ".7z", ".dmg", ".rar", ".xar", ".zip"], "AUDIO": [".aac", ".aa", ".aac", ".dvf", ".m4a", ".m4b", ".m4p", ".mp3", ".msv", "ogg", "oga", ".raw", ".vox", ".wav", ".wma"], } FILE_FORMATS = {file_format: directory for directory, file_formats in DIRECTORIES.items() for file_format in file_formats} def organize_junk(): for entry in os.scandir(): if entry.is_dir(): continue file_path = Path(entry) file_format = file_path.suffix.lower() if file_format in FILE_FORMATS: directory_path = Path(FILE_FORMATS[file_format]) directory_path.mkdir(exist_ok=True) file_path.rename(directory_path.joinpath(file_path)) for dir in os.scandir(): try: os.rmdir(dir) except: pass if __name__ == "__main__": organize_junk()**main code**
import tkinter import time from tkinter import ttk from tkinter import * import tkinter as tk import time import sys import os import subprocess import idlelib import urllib.request import ctypes import functools from tkinter import PhotoImage import webbrowser from tkinter import messagebox import pymsgbox ################################### master = Tk() master.configure(background = 'pink') master_height = 400 master_width = 1000 screen_width = master.winfo_screenwidth() screen_height = master.winfo_screenheight() x_cordinate = int((screen_width/2) - (master_width/2)) y_cordinate = int((screen_height/2) - (master_height/2)) master.geometry("{}x{}+{}+{}".format(master_width, master_height, x_cordinate, y_cordinate)) ################################### time1 = '' clock = Label(master, font=('times', 20, 'bold')) clock.place(x=260, y=260) def tick(): global time1 time2 = time.strftime('%H:%M:%S') if time2 != time1: time1 = time2 clock.config(text=time2) clock.after(200, tick) def downloads(): for x in range(1, 110): progress_var.set(x) time.sleep(0.10) master.update() progress_var.set(0) if True: os.startfile("C:/Users/Nelson/Downloads/") def musicas(): for x in range(1, 110): progress_var.set(x) time.sleep(0.10) master.update() progress_var.set(0) if True: os.startfile("C:/Users/Nelson/Music/") def imagens(): for x in range(1, 110): progress_var.set(x) time.sleep(0.10) master.update() progress_var.set(0) if True: os.startfile("C:/Users/Nelson/Pictures/") def videos(): for x in range(1, 110): progress_var.set(x) time.sleep(0.10) master.update() progress_var.set(0) if True: os.startfile("C:/Users/Nelson/Videos/") def documentos(): for x in range(1, 110): progress_var.set(x) time.sleep(0.10) master.update() progress_var.set(0) if True: os.startfile("C:/Users/Nelson/Documents/") def organizador(): for x in range(1, 110): progress_var.set(x) time.sleep(0.10) master.update() progress_var.set(0) if True: path = "C:/Users/Nelson/Desktop/Folder 1" os.chdir(path) os.system("organizer.exe") path = "C:/Users/Nelson/Desktop/Folder 2" os.chdir(path) os.system("organizer.exe") path = "C:/Users/Nelson/Desktop/Folder 3" os.chdir(path) os.system("organizer.exe") path = "C:/Users/Nelson/Desktop/Folder 4" os.chdir(path) os.system("organizer.exe") progress_var = tkinter.IntVar() pb = ttk.Progressbar(master, orient="horizontal", length=400, maximum=100, mode="determinate", var=progress_var) pb.grid(padx=100, pady=300) ######################################################################################### photo1=PhotoImage(file="downloads.png") b1 = Button(master,image=photo1, command=downloads, height=200, width=200, bg='blue', compound=LEFT) b1.place(x = 0, y = 0)# x = mexe na horizontal e y = mexe na vertical photo2=PhotoImage(file="musica.png") b2 = Button(master,image=photo2, command=musicas, height=200, width=200, bg='green', compound=LEFT) b2.place(x = 200, y = 0)# x = mexe na horizontal e y = mexe na vertical photo3=PhotoImage(file="imagens.png") b3 = Button(master,image=photo3, command=imagens, height=200, width=200, bg='yellow', compound=LEFT) b3.place(x = 400, y = 0)# x = mexe na horizontal e y = mexe na vertical photo4=PhotoImage(file="videos.png") b4 = Button(master,image=photo4, command=videos, height=200, width=200, bg='purple', compound=LEFT) b4.place(x = 600, y = 0)# x = mexe na horizontal e y = mexe na vertical photo5=PhotoImage(file="documentos.png") b5 = Button(master,image=photo5, command=documentos, height=200, width=200, bg='orange', compound=LEFT) b5.place(x = 800, y = 0)# x = mexe na horizontal e y = mexe na vertical photo6=PhotoImage(file="sos.png") b6 = Button(master,image=photo6, command=organizador, height=200, width=200, bg='wheat1', compound=LEFT) b6.place(x = 800, y = 200)# x = mexe na horizontal e y = mexe na vertical #################################### tick() master.resizable(False, False) master.mainloop() ###################################This program works like a charm, i have a lady that as almost 50000 photos, 20000 videos and so on,imagine how difficult is to organize all that, just put the file in the folders and the program will do that for me.