Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import shutil
- from tqdm import tqdm
- print("Organização de Arquivos")
- def move_files_to_images_folder():
- current_path = os.getcwd()
- images_folder = os.path.join(current_path, "Imagens")
- if not os.path.exists(images_folder):
- os.makedirs(images_folder)
- files = os.listdir(current_path)
- image_files = [file for file in files if file.lower().endswith((".png", ".jpg", ".jpeg"))]
- for file in tqdm(image_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(images_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Imagens'.")
- def move_files_to_icons_folder():
- current_path = os.getcwd()
- icons_folder = os.path.join(current_path, "Icones")
- if not os.path.exists(icons_folder):
- os.makedirs(icons_folder)
- files = os.listdir(current_path)
- icon_files = [file for file in files if file.lower().endswith(".ico")]
- for file in tqdm(icon_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(icons_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Icones'.")
- def move_files_to_archives_folder():
- current_path = os.getcwd()
- archives_folder = os.path.join(current_path, "Compactados")
- if not os.path.exists(archives_folder):
- os.makedirs(archives_folder)
- files = os.listdir(current_path)
- archive_files = [file for file in files if file.lower().endswith((".zip", ".rar"))]
- for file in tqdm(archive_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(archives_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Compactados'.")
- def move_files_to_videos_folder():
- current_path = os.getcwd()
- videos_folder = os.path.join(current_path, "Videos")
- if not os.path.exists(videos_folder):
- os.makedirs(videos_folder)
- files = os.listdir(current_path)
- video_files = [file for file in files if file.lower().endswith((".mp4", ".mkv", ".ts", ".flv", ".mov"))]
- for file in tqdm(video_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(videos_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Videos'.")
- def move_files_to_text_documents_folder():
- current_path = os.getcwd()
- text_documents_folder = os.path.join(current_path, "Textos e Documentos")
- if not os.path.exists(text_documents_folder):
- os.makedirs(text_documents_folder)
- files = os.listdir(current_path)
- text_doc_files = [file for file in files if file.lower().endswith((".txt", ".doc", ".pdf"))]
- for file in tqdm(text_doc_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(text_documents_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Textos e Documentos'.")
- def move_files_to_dvd_folder():
- current_path = os.getcwd()
- dvd_folder = os.path.join(current_path, "Filmes DVD-R")
- if not os.path.exists(dvd_folder):
- os.makedirs(dvd_folder)
- files = os.listdir(current_path)
- dvd_files = [file for file in files if file.lower().endswith(".iso")]
- for file in tqdm(dvd_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(dvd_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Filmes DVD-R'.")
- def move_files_to_programming_folder():
- current_path = os.getcwd()
- programming_folder = os.path.join(current_path, "Programação PHP")
- if not os.path.exists(programming_folder):
- os.makedirs(programming_folder)
- files = os.listdir(current_path)
- programming_files = [file for file in files if file.lower().endswith((".php", ".sql"))]
- for file in tqdm(programming_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(programming_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Programação PHP'.")
- def move_files_to_music_folder():
- current_path = os.getcwd()
- music_folder = os.path.join(current_path, "Músicas")
- if not os.path.exists(music_folder):
- os.makedirs(music_folder)
- files = os.listdir(current_path)
- music_files = [file for file in files if file.lower().endswith((".mp3", ".wav", ".flac"))]
- for file in tqdm(music_files, desc="Movendo arquivos"):
- file_path = os.path.join(current_path, file)
- destination_path = os.path.join(music_folder, file)
- shutil.move(file_path, destination_path)
- print("Arquivos movidos com sucesso para a subpasta 'Músicas'.")
- def show_menu():
- print("1 - Mover extensão .png, .jpg, .jpeg")
- print("2 - Mover extensão .ico")
- print("3 - Mover extensão .zip, .rar")
- print("4 - Mover extensão .mp4, .mkv, .ts, .flv, .mov")
- print("5 - Mover extensão .txt, .doc, .pdf")
- print("6 - Mover extensão .iso")
- print("7 - Mover extensão .php, .sql")
- print("8 - Mover extensão .mp3, .wav, .flac")
- print("9 - Sair (Pressione a barra de espaço para fechar)")
- def main():
- while True:
- show_menu()
- choice = input("Escolha uma opção: ")
- if choice == "1":
- move_files_to_images_folder()
- elif choice == "2":
- move_files_to_icons_folder()
- elif choice == "3":
- move_files_to_archives_folder()
- elif choice == "4":
- move_files_to_videos_folder()
- elif choice == "5":
- move_files_to_text_documents_folder()
- elif choice == "6":
- move_files_to_dvd_folder()
- elif choice == "7":
- move_files_to_programming_folder()
- elif choice == "8":
- move_files_to_music_folder()
- elif choice == "9":
- break
- else:
- print("Opção inválida. Tente novamente.")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement