From 287fdcb6c96495248dd015e3a4f6fb3fba0cdb6c Mon Sep 17 00:00:00 2001 From: Luis Rodrigues Date: Wed, 16 Apr 2025 19:12:34 +0100 Subject: [PATCH] =?UTF-8?q?cria=C3=A7=C3=A3o=20da=20fun=C3=A7=C3=A3o=20cat?= =?UTF-8?q?egorizar=5Fpor=5Ftipo()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- organizer.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/organizer.py b/organizer.py index 623b9a9..15639be 100644 --- a/organizer.py +++ b/organizer.py @@ -1,12 +1,22 @@ # organizer.py # Funções para categorizar ficheiros e criar estrutura de destino +from pathlib import Path -def categorizar_por_tipo(ficheiro): +def categorizar_por_tipo(ficheiro: str) -> str: """ Devolve o tipo de ficheiro (imagem, documento, vídeo, etc) com base na extensão. """ - pass + # TODO: extensões configuraveis externamente pelo utilizador + extensao = Path(ficheiro).suffix.lower().lstrip('.') + if extensao in ['jpeg', 'jpg', 'bmp', 'cr2', 'raw']: + return 'imagem' + elif extensao in ['pdf', 'doc', 'docx', 'xls', 'xlsx']: + return 'documento' + elif extensao in ['mp4', 'mpeg', 'mov']: + return 'video' + else: + return 'outros' def categorizar_por_data(ficheiro):