• Salut Visiteur ! ✌
    Découvre nos partenaires officiels avec VeryLeak's. Des choix réfléchis, dignes de confiance pour tes avantages.

    StoryFound | REFUNDER TEAM

    StoryFound

    Rejoindre le Canal ✨ ou Plus d'information 📃

    Une question ? Rejoingnez nos différents canaux (Discord, Telegram, Revolt)

    Nos Canaux Communautaires

    Cet affichage peut se clôturer définitivement via la croix en haut à droite.

UPDATED! AFO (Automatic File Organizer)

Trk213

l'Accru 🥇
Level 1

Torrents Stats

Messages
39
J'aime
2
Trophées
141
Inscrit
20 Septembre 2019
Salut tout le monde!

J'en avais marre de tout le temps creer des dossiers pour ensuite bouger les fichiers dedans à chaque fois donc j'ai codé un petit programme en Python qui gere le fichier download en classant automatiquement pour vous les fichiers. Et puisque c'est un forum ou le but est de télécharger, j'ai pensé que ça pourrait être utile.


Vous avez seulement besoin de:
- Python (https://www.python.org/downloads/release/python-380/)

ps:
Si vous avez des extensions qui ne sont pas automatiquement bougées vers des dossiers, s'il vous plaît mentionnez-le, je vais le corriger. (Même chose pour les bugs)

Capture.PNG

Capture.PNG

Capture1.PNG
 

Fichiers joints

  • AFO (Automatic File Organizer) .zip
    2 KB · Affichages: 6
Dernière édition:

Bl4ckH3ll

l'Actif 🥉
Level 1

Torrents Stats

Messages
5
J'aime
0
Trophées
46
Inscrit
11 Mai 2020
Bonsoir,

Merci pour le partage !, je pense reprendre ton script afin de l'adapter a mon utilisation.

Quelques petites pistes d’améliorations:
-Mettre un message d'erreur ou demander le chemin lors du choix du dossier si un dossier n'est pas trouver (ex: dossier document qui n'est pas le chemin de base Windows le script ce ferme)

-Rajouter certaines extensions communes: .docx, .torrent (peut être même un dossier torrent), .apk, .sh, .bat,)
 

Bl4ckH3ll

l'Actif 🥉
Level 1

Torrents Stats

Messages
5
J'aime
0
Trophées
46
Inscrit
11 Mai 2020
Du coup j'ai un peut modifier

Python:
import os
import shutil
import sys
from time import sleep
from pathlib import Path

#Dictionnaire
DIRECTORIES = {
    "HTML": [".html5", ".html", ".htm", ".xhtml"],
    "IMAGES": [".jpeg", ".jpg", ".tiff", ".gif", ".bmp", ".png", ".bpg", "svg",
               ".heif", ".psd"],
    "VIDEOS": [".avi", ".flv", ".wmv", ".mov", ".mp4", ".webm", ".vob", ".mng",
               ".qt", ".mpg", ".mpeg", ".3gp", ".mkv"],
    "DOCUMENTS": [".oxps", ".epub", ".pages", ".docx", ".doc", ".fdf", ".ods",
                  ".odt", ".pwi", ".xsn", ".xps", ".dotx", ".docm", ".dox",
                  ".rvg", ".rtf", ".rtfd", ".wpd", ".xls", ".xlsx", ".ppt",
                  "pptx"],
    "ARCHIVES": [".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"],
    "PLAINTEXT": [".txt", ".in", ".out"],
    "PDF": [".pdf"],
    "PYTHON": [".py"],
    "XML": [".xml"],
    "EXE": [".exe"],
    "SHELL": [".sh"]
}

def type(text):
    words = text
    for char in words:
        sleep(0.000001)
        sys.stdout.write(char)
        sys.stdout.flush()


def type2(text):
    words = text
    for char in words:
        sleep(0.03)
        sys.stdout.write(char)
        sys.stdout.flush()


currentUser = os.getlogin()
type('''
──────────────────────────────────────────────
─██████████████─██████████████─██████████████─
─██░░░░░░░░░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─
─██░░██████░░██─██░░██████████─██░░██████░░██─
─██░░██──██░░██─██░░██─────────██░░██──██░░██─
─██░░██████░░██─██░░██████████─██░░██──██░░██─
─██░░░░░░░░░░██─██░░░░░░░░░░██─██░░██──██░░██─
─██░░██████░░██─██░░██████████─██░░██──██░░██─
─██░░██──██░░██─██░░██─────────██░░██──██░░██─
─██░░██──██░░██─██░░██─────────██░░██████░░██─
─██░░██──██░░██─██░░██─────────██░░░░░░░░░░██─
─██████──██████─██████─────────██████████████─
──────────────────────────────────────────────\n''')
sleep(1)
type2(f'Hi {currentUser}!\n')
type2(f'Welcome to AFO, (Automatic File Organizer).\n')
type2('Thought and coded by [email protected]\n')

sleep(2)
type('──────────────────────────────────────────────\n')
sleep(0.3)
type2('What do you want to organize? <:\n')
type2('Downloads [1]\n')
type2('Documents [2]\n')
type2('Help & Details [3]\n')
sleep(0.3)
answer = input('> ')
type('──────────────────────────────────────────────\n')
answered = True


def AFOdocuments():
    type2('Checking if directories exist.....\n')
    sleep(1)
    #Documents folder
    os.chdir('C:/Users/{currentUser}/Documents/')

    FILE_FORMATS = {file_format: directory
                    for directory, file_formats in DIRECTORIES.items()
                    for file_format in file_formats}

    # This will organise your files
    def organize():
        for entry in os.scandir():
            if entry.is_dir():
                continue
            file_path = Path(entry.name)
            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))
        # if extension not present in the dctionary than create a folder name "OTHER"
        try:
            os.mkdir("OTHER")
        except:
            pass
        for dir in os.scandir():
            try:
                if dir.is_dir():
                    os.rmdir(dir)
                else:
                    os.rename(os.getcwd() + '/' + str(Path(dir)), os.getcwd() + '/OTHER/' + str(Path(dir)))
            except:
                pass

    if __name__ == "__main__":
        organize()

    type2('Moving files.\n')
    sleep(1)
    type2('──────────────────────────────────────────────\n')


def AFOdownload():
    type2('Checking if directories exist.....\n')
    sleep(1)
    # Download Folder
    os.chdir('C:/Users/{currentUser}/Downloads/')

    FILE_FORMATS = {file_format: directory
                    for directory, file_formats in DIRECTORIES.items()
                    for file_format in file_formats}

    # This will organise your files
    def organize():
        for entry in os.scandir():
            if entry.is_dir():
                continue
            file_path = Path(entry.name)
            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))
        # if extension not present in the dctionary than create a folder name "OTHER"
        try:
            os.mkdir("OTHER")
        except:
            pass
        for dir in os.scandir():
            try:
                if dir.is_dir():
                    os.rmdir(dir)
                else:
                    os.rename(os.getcwd() + '/' + str(Path(dir)), os.getcwd() + '/OTHER/' + str(Path(dir)))
            except:
                pass

    if __name__ == "__main__":
        organize()

    type2('Moving files.\n')
    sleep(1)
    type2('──────────────────────────────────────────────\n')


while answered == True:
    if answer == '1':
        answered = False
        AFOdownload()
    elif answer == '2':
        answered = False
        AFOdocuments()
    elif answer == '3':
        type2('AFO will create folders on a previously selected path [1] for your Downloads path and [2] for your Documents path. It will use the folders to move files into them depending on their extensions.\n')
        sleep(1.5)
        type2('A little example; a .txt or a doc file will be moved in a folder called TXT_FILES. A .mp4 or m4v file will be moved in a folder called VIDEOS and it goes on.\n')
        sleep(1.5)
        type2('Now that you understood, please choose an option below.\n')
        sleep(1.5)
        type2('What do you want to organize? <:\n')
        type2('Downloads [1]\n')
        type2('Documents [2]\n')
        type2('Help & Details [3]\n')
        sleep(0.3)
        answer = int(input('> '))
        type('──────────────────────────────────────────────\n')
    else:
        type2("Woops I didn't get it, it looks like an invalid answer!\n")
        sleep(1)
        type2('if you think this was a bug, please report it at [email protected].\n')
        sleep(0.7)
        type2("Please try again.\n")
        sleep(1.5)
        type2('What do you want to organize? <:\n')
        type2('Downloads [1]\n')
        type2('Documents [2]\n')
        type2('Help & Details [3]\n')
        sleep(0.3)
        answer = input('> ')
        type('──────────────────────────────────────────────\n')

type('──────────────────────────────────────────────\n')
type2('AFO has been executed successfully without errors.\n')
sleep(1.5)
type2('Closing program.')
sleep(1.5)
 

Luzeurodoff

l'Actif 🥉
Level 1

Torrents Stats

Messages
41
J'aime
3
Trophées
46
Inscrit
14 Mai 2020
Merci c'est hyper pratique !
 
Haut Bas