Advertisement
sneezedip

Untitled

Mar 1st, 2023
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 19.89 KB | None | 0 0
  1. import os
  2. import shutil
  3. import time
  4. from colorama import Fore, Style
  5. import msvcrt as key
  6. import tkinter as tk
  7. from tkinter import filedialog
  8.  
  9. root = tk.Tk()
  10. root.withdraw()
  11. textfiles = "X"
  12. pythonfiles = "X"
  13. pdffiles = "X"
  14. wordsfiles = "X"
  15. powerfiles = "X"
  16. excelfiles = "X"
  17. compfiles = "X"
  18. images = "X"
  19. audiofiles = "X"
  20. videofiles = "X"
  21. programs = "X"
  22. shortcuts = "X"
  23. allinone = ""
  24. valid_inputs = {b'0', b'1', b'2', b'3', b'4',
  25.                 b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd'}
  26. valid_inputs1 = {b'1', b'2', b'p', b'q'}
  27. python_folder = ""
  28.  
  29. user_name = os.getlogin()
  30. desktopdir = f"C:\\Users\\{user_name}\\Desktop\\"
  31.  
  32.  
  33. def console():
  34.     os.system('cls')
  35.     print(Fore.BLUE + Style.BRIGHT, """
  36.     ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄     ▄▄▄▄▄▄▄    ▄▄▄▄▄▄▄ ▄▄▄▄▄▄   ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄    ▄ ▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄
  37.    █       █   █   █   █       █  █       █   ▄  █ █       █       █  █  █ █   █       █       █   ▄  █
  38.    █    ▄▄▄█   █   █   █    ▄▄▄█  █   ▄   █  █ █ █ █   ▄▄▄▄█   ▄   █   █▄█ █   █▄▄▄▄   █    ▄▄▄█  █ █ █
  39.    █   █▄▄▄█   █   █   █   █▄▄▄   █  █ █  █   █▄▄█▄█  █  ▄▄█  █▄█  █       █   █▄▄▄▄█  █   █▄▄▄█   █▄▄█▄
  40.    █    ▄▄▄█   █   █▄▄▄█    ▄▄▄█  █  █▄█  █    ▄▄  █  █ █  █       █  ▄    █   █ ▄▄▄▄▄▄█    ▄▄▄█    ▄▄  █
  41.    █   █   █   █       █   █▄▄▄   █       █   █  █ █  █▄▄█ █   ▄   █ █ █   █   █ █▄▄▄▄▄█   █▄▄▄█   █  █ █
  42.    █▄▄▄█   █▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█  █▄▄▄▄▄▄▄█▄▄▄█  █▄█▄▄▄▄▄▄▄█▄▄█ █▄▄█▄█  █▄▄█▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄█  █▄█
  43.  
  44.    """, Style.RESET_ALL)
  45.     print(Style.BRIGHT, f"""
  46.    {Fore.WHITE}[1] - {Fore.GREEN}Run with default settings
  47.    {Fore.WHITE}[2] - {Fore.YELLOW}Run with custom settings
  48.    
  49.  
  50.    {Fore.GREEN}[CURRENT DIRECTORY] - {Fore.RED}{desktopdir}
  51.    {Fore.GREEN}[P] - {Fore.RED}Change Directory
  52.    {Fore.GREEN}[Q] - {Fore.RED}Exit
  53.    """, Style.RESET_ALL)
  54.     user_input = key.getch()
  55.     if user_input in valid_inputs1:
  56.         if user_input == b'1':
  57.             main()
  58.         if user_input == b'2':
  59.             custom()
  60.         if user_input == b'p':
  61.             directorychange()
  62.         if user_input == b'q':
  63.             quit()
  64.     else:
  65.         os.system('cls')
  66.         console()
  67.  
  68.  
  69. def custom():
  70.     os.system('cls')
  71.     global textfiles, pythonfiles, pdffiles, wordsfiles, powerfiles, excelfiles, compfiles, images, audiofiles, videofiles, programs, shortcuts, valid_inputs, allinone
  72.  
  73.     print(Fore.BLUE + Style.BRIGHT, """
  74.     ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ ▄▄    ▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄
  75.    █       █       █       █       █   █  █  █ █       █       █
  76.    █  ▄▄▄▄▄█    ▄▄▄█▄     ▄█▄     ▄█   █   █▄█ █   ▄▄▄▄█  ▄▄▄▄▄█
  77.    █ █▄▄▄▄▄█   █▄▄▄  █   █   █   █ █   █       █  █  ▄▄█ █▄▄▄▄▄
  78.    █▄▄▄▄▄  █    ▄▄▄█ █   █   █   █ █   █  ▄    █  █ █  █▄▄▄▄▄  █
  79.    ▄▄▄▄▄█ █   █▄▄▄  █   █   █   █ █   █ █ █   █  █▄▄█ █▄▄▄▄▄█ █
  80.    █▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█ █▄▄▄█   █▄▄▄█ █▄▄▄█▄█  █▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█
  81.  
  82.    """, Style.RESET_ALL)
  83.  
  84.     print(Fore.BLUE + Style.BRIGHT, f"""
  85.    {Fore.WHITE}[1] - {Fore.CYAN}Text files {Fore.RED}[{textfiles}]
  86.    {Fore.WHITE}[2] - {Fore.CYAN}Programming Files (ALL) {Fore.RED}[{pythonfiles}]
  87.    {Fore.WHITE}[3] - {Fore.CYAN}PDF files {Fore.RED}[{pdffiles}]
  88.    {Fore.WHITE}[4] - {Fore.CYAN}Words files {Fore.RED}[{wordsfiles}]
  89.    {Fore.WHITE}[5] - {Fore.CYAN}Power files {Fore.RED}[{powerfiles}]
  90.    {Fore.WHITE}[6] - {Fore.CYAN}Excel files {Fore.RED}[{excelfiles}]
  91.    {Fore.WHITE}[7] - {Fore.CYAN}Compressed files {Fore.RED}[{compfiles}]
  92.    {Fore.WHITE}[8] - {Fore.CYAN}Images {Fore.RED}[{images}]
  93.    {Fore.WHITE}[9] - {Fore.CYAN}Audio files {Fore.RED}[{audiofiles}]
  94.    {Fore.WHITE}[a] - {Fore.CYAN}Video files {Fore.RED}[{videofiles}]
  95.    {Fore.WHITE}[b] - {Fore.CYAN}Programs {Fore.RED}[{programs}]
  96.    {Fore.WHITE}[c] - {Fore.CYAN}Shortcuts {Fore.RED}[{shortcuts}]
  97.  
  98.    {Fore.WHITE}[d] - {Fore.YELLOW}ALL IN ONE FOLDER {Fore.RED}[{allinone}]
  99.  
  100.  
  101.    {Fore.WHITE}[0] - {Fore.RED}RUN PROGRAM
  102.  
  103.    """, Style.RESET_ALL)
  104.     try:
  105.         user_input = key.getch()
  106.         if user_input in valid_inputs:
  107.             if len(user_input) == 1:
  108.                 if user_input == b'1':
  109.                     if textfiles == "X":
  110.                         textfiles = ""
  111.                         os.system('cls')
  112.                         custom()
  113.                     else:
  114.                         textfiles = "X"
  115.                         os.system('cls')
  116.                         custom()
  117.                 if user_input == b'2':
  118.                     if pythonfiles == "X":
  119.                         pythonfiles = ""
  120.                         os.system('cls')
  121.                         custom()
  122.                     else:
  123.                         pythonfiles = "X"
  124.                         os.system('cls')
  125.                         custom()
  126.                 if user_input == b'3':
  127.                     if pdffiles == "X":
  128.                         pdffiles = ""
  129.                         os.system('cls')
  130.                         custom()
  131.                     else:
  132.                         pdffiles = "X"
  133.                         os.system('cls')
  134.                         custom()
  135.                 if user_input == b'4':
  136.                     if wordsfiles == "X":
  137.                         wordsfiles = ""
  138.                         os.system('cls')
  139.                         custom()
  140.                     else:
  141.                         wordsfiles = "X"
  142.                         os.system('cls')
  143.                         custom()
  144.                 if user_input == b'5':
  145.                     if powerfiles == "X":
  146.                         powerfiles = ""
  147.                         os.system('cls')
  148.                         custom()
  149.                     else:
  150.                         powerfiles = "X"
  151.                         os.system('cls')
  152.                         custom()
  153.                 if user_input == b'6':
  154.                     if excelfiles == "X":
  155.                         excelfiles = ""
  156.                         os.system('cls')
  157.                         custom()
  158.                     else:
  159.                         excelfiles = "X"
  160.                         os.system('cls')
  161.                         custom()
  162.                 if user_input == b'7':
  163.                     if compfiles == "X":
  164.                         compfiles = ""
  165.                         os.system('cls')
  166.                         custom()
  167.                     else:
  168.                         compfiles = "X"
  169.                         os.system('cls')
  170.                         custom()
  171.                 if user_input == b'8':
  172.                     if images == "X":
  173.                         images = ""
  174.                         os.system('cls')
  175.                         custom()
  176.                     else:
  177.                         images = "X"
  178.                         os.system('cls')
  179.                         custom()
  180.                 if user_input == b'9':
  181.                     if audiofiles == "X":
  182.                         audiofiles = ""
  183.                         os.system('cls')
  184.                         custom()
  185.                     else:
  186.                         audiofiles = "X"
  187.                         os.system('cls')
  188.                         custom()
  189.                 if user_input == b'a':
  190.                     if videofiles == "X":
  191.                         videofiles = ""
  192.                         os.system('cls')
  193.                         custom()
  194.                     else:
  195.                         videofiles = "X"
  196.                         os.system('cls')
  197.                         custom()
  198.                 if user_input == b'b':
  199.                     if programs == "X":
  200.                         programs = ""
  201.                         os.system('cls')
  202.                         custom()
  203.                     else:
  204.                         programs = "X"
  205.                         os.system('cls')
  206.                         custom()
  207.                 if user_input == b'c':
  208.                     if shortcuts == "X":
  209.                         shortcuts = ""
  210.                         os.system('cls')
  211.                         custom()
  212.                     else:
  213.                         shortcuts = "X"
  214.                         os.system('cls')
  215.                         custom()
  216.                 if user_input == b'd':
  217.                     if allinone == "X":
  218.                         allinone = ""
  219.                         os.system('cls')
  220.                         custom()
  221.                     else:
  222.                         allinone = "X"
  223.                         os.system('cls')
  224.                         custom()
  225.                 if user_input == b'0':
  226.                     os.system('cls')
  227.                     main()
  228.                 else:
  229.                     pass
  230.             else:
  231.                 print(Fore.RED, "Error.")
  232.                 time.sleep(1)
  233.                 os.system('cls')
  234.                 custom()
  235.         else:
  236.             os.system('cls')
  237.             custom()
  238.     except Exception as e:
  239.         print(f"Error: {e}")
  240.         pass
  241.  
  242.  
  243. def main():
  244.     os.system('cls')
  245.     global root, python_folder, py_folder, desktopdir
  246.  
  247.     print(Fore.BLUE + Style.BRIGHT, "Executing program with current settings...")
  248.     for root, dirs, files in os.walk(desktopdir, topdown=True):
  249.         if root == desktopdir:
  250.             for name in files:
  251.                 os.chdir(desktopdir)
  252.                 if textfiles == True or textfiles == "X":
  253.                     try:
  254.                         if name.endswith('.txt'):
  255.                             txt_folder = os.path.join(desktopdir, "Text Files")
  256.                             if not os.path.exists(txt_folder):
  257.                                 os.mkdir(txt_folder)
  258.                             shutil.move(os.path.join(root, name), txt_folder)
  259.                     except:
  260.                         pass
  261.                 else:
  262.                     pass
  263.                 if pythonfiles == True or pythonfiles == "X":
  264.                     try:
  265.                         if name.endswith('.py') or name.endswith('.pyw'):
  266.                             py_folder = os.path.join(
  267.                                 desktopdir, "Python Files")
  268.                             if not os.path.exists(py_folder):
  269.                                 os.mkdir(py_folder)
  270.                             shutil.move(os.path.join(root, name), py_folder)
  271.                         if name.endswith('.cpp') or name.endswith('.c++') or name.endswith('.c') or name.endswith('.cc') or name.endswith('.cp') or name.endswith('.cxx') or name.endswith('.h') or name.endswith('.h++') or name.endswith('.hh') or name.endswith('.hpp') or name.endswith('.hxx') or name.endswith('.inc') or name.endswith('.inl') or name.endswith('.ipp') or name.endswith('.tcc') or name.endswith('.tpp'):
  272.                             c_folder = os.path.join(
  273.                                 desktopdir, "C++ Files")
  274.                             if not os.path.exists(c_folder):
  275.                                 os.mkdir(c_folder)
  276.                             shutil.move(os.path.join(root, name), c_folder)
  277.                         if name.endswith('.java'):
  278.                             java_folder = os.path.join(
  279.                                 desktopdir, "Java Files")
  280.                             if not os.path.exists(java_folder):
  281.                                 os.mkdir(java_folder)
  282.                             shutil.move(os.path.join(root, name), java_folder)
  283.  
  284.                     except:
  285.                         pass
  286.                 else:
  287.                     pass
  288.                 if pdffiles == True or pdffiles == "X":
  289.                     try:
  290.                         if name.endswith('.pdf'):
  291.                             pdf_folder = os.path.join(desktopdir, "PDF Files")
  292.                             if not os.path.exists(pdf_folder):
  293.                                 os.mkdir(pdf_folder)
  294.                                 shutil.move(os.path.join(
  295.                                     root, name), pdf_folder)
  296.                     except:
  297.                         pass
  298.                 else:
  299.                     pass
  300.                 if wordsfiles == True or wordsfiles == "X":
  301.                     try:
  302.                         if name.endswith('.docx') or name.endswith('.doc'):
  303.                             docx_folder = os.path.join(
  304.                                 desktopdir, "Word Files")
  305.                             if not os.path.exists(docx_folder):
  306.                                 os.mkdir(docx_folder)
  307.                             shutil.move(os.path.join(root, name), docx_folder)
  308.                     except:
  309.                         pass
  310.                 else:
  311.                     pass
  312.                 if powerfiles == True or powerfiles == "X":
  313.                     try:
  314.                         if name.endswith('.pptx') or name.endswith('.ppt') or name.endswith('.key') or name.endswith('.odp') or name.endswith('.pps'):
  315.                             pptx_folder = os.path.join(
  316.                                 desktopdir, "PowerPoint Files")
  317.                             if not os.path.exists(pptx_folder):
  318.                                 os.mkdir(pptx_folder)
  319.                             shutil.move(os.path.join(root, name), pptx_folder)
  320.                     except:
  321.                         pass
  322.                 else:
  323.                     pass
  324.                 if excelfiles == True or excelfiles == "X":
  325.                     try:
  326.                         if name.endswith('.xlsx') or name.endswith('.xls'):
  327.                             xlsx_folder = os.path.join(
  328.                                 desktopdir, "Excel Files")
  329.                             if not os.path.exists(xlsx_folder):
  330.                                 os.mkdir(xlsx_folder)
  331.                             shutil.move(os.path.join(root, name), xlsx_folder)
  332.                     except:
  333.                         pass
  334.                 else:
  335.                     pass
  336.                 if compfiles == True or compfiles == "X":
  337.                     try:
  338.                         if name.endswith('.zip') or name.endswith('.rar') or name.endswith('.7z') or name.endswith('.arj') or name.endswith('.deb') or name.endswith('.pkg') or name.endswith('.rpm') or name.endswith('.z'):
  339.                             zip_folder = os.path.join(
  340.                                 desktopdir, "Compressed Files")
  341.                             if not os.path.exists(zip_folder):
  342.                                 os.mkdir(zip_folder)
  343.                             shutil.move(os.path.join(root, name), zip_folder)
  344.                     except:
  345.                         pass
  346.                 else:
  347.                     pass
  348.                 if images == True or images == "X":
  349.                     try:
  350.                         if name.endswith('.jpg') or name.endswith('.jpeg') or name.endswith('.png') or name.endswith('.gif') or name.endswith('.jfif') or name.endswith('.ico') or name.endswith('.psd'):
  351.                             img_folder = os.path.join(desktopdir, "Images")
  352.                             if not os.path.exists(img_folder):
  353.                                 os.mkdir(img_folder)
  354.                             shutil.move(os.path.join(root, name), img_folder)
  355.                     except:
  356.                         pass
  357.                 else:
  358.                     pass
  359.                 if audiofiles == True or audiofiles == "X":
  360.                     try:
  361.                         if name.endswith('.mp3') or name.endswith('.wma'):
  362.                             mp3_folder = os.path.join(
  363.                                 desktopdir, "Audio Files")
  364.                             if not os.path.exists(mp3_folder):
  365.                                 os.mkdir(mp3_folder)
  366.                             shutil.move(os.path.join(root, name), mp3_folder)
  367.                     except:
  368.                         pass
  369.                 else:
  370.                     pass
  371.                 if videofiles == True or videofiles == "X":
  372.                     try:
  373.                         if name.endswith('.mp4') or name.endswith('.avi'):
  374.                             mp4_folder = os.path.join(
  375.                                 desktopdir, "Video Files")
  376.                             if not os.path.exists(mp4_folder):
  377.                                 os.mkdir(mp4_folder)
  378.                             shutil.move(os.path.join(root, name), mp4_folder)
  379.                     except:
  380.                         pass
  381.                 else:
  382.                     pass
  383.                 if programs == True or programs == "X":
  384.                     try:
  385.                         if name.endswith('.exe') or name.endswith('.msi') or name.endswith('.bat'):
  386.                             program_folder = os.path.join(
  387.                                 desktopdir, "Programs")
  388.                             if not os.path.exists(program_folder):
  389.                                 os.mkdir(program_folder)
  390.                             shutil.move(os.path.join(
  391.                                 root, name), program_folder)
  392.                     except:
  393.                         pass
  394.                 else:
  395.                     pass
  396.                 if shortcuts == True or shortcuts == "X":
  397.                     try:
  398.                         if name.endswith('.lnk'):
  399.                             shortcuts_folder = os.path.join(
  400.                                 desktopdir, "Shortcuts")
  401.                             if not os.path.exists(shortcuts_folder):
  402.                                 os.mkdir(shortcuts_folder)
  403.                             shutil.move(os.path.join(root, name),
  404.                                         shortcuts_folder)
  405.                     except:
  406.                         pass
  407.                 else:
  408.                     pass
  409.         else:
  410.             break
  411.         if allinone == True or allinone == "X":
  412.             allfolder = os.path.join(
  413.                 desktopdir, "All Folders")
  414.             if not os.path.exists(allfolder):
  415.                 os.mkdir(allfolder)
  416.             for item in os.listdir(desktopdir):
  417.                 item_path = os.path.join(desktopdir, item)
  418.  
  419.                 if os.path.isdir(item_path):
  420.                     try:
  421.                         shutil.move(item_path, allfolder)
  422.                     except:
  423.                         pass
  424.         else:
  425.             pass
  426.         print("Done.")
  427.         time.sleep(0.5)
  428.         print(Fore.BLUE + Style.BRIGHT,
  429.               "Press any key to leave...", Style.RESET_ALL)
  430.         key.getch()
  431.         os.system('cls')
  432.  
  433.  
  434. def directorychange():
  435.     global desktopdir
  436.     os.system('cls')
  437.     print(Fore.BLUE + Style.BRIGHT,
  438.           "Press any key to change directory...", Style.RESET_ALL)
  439.     key.getch()
  440.     os.system('cls')
  441.     print(Fore.BLUE + Style.BRIGHT,
  442.           "Enter the new directory...", Style.RESET_ALL)
  443.     desktopdir = filedialog.askdirectory()
  444.     print(Fore.BLUE + Style.BRIGHT,
  445.           f"""{Fore.GREEN}New Directory : {desktopdir}\n{Fore.YELLOW}Press any key to continue...
  446.          """, Style.RESET_ALL)
  447.     key.getch()
  448.     os.system('cls')
  449.     console()
  450.  
  451.  
  452. console()
  453.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement