Répondre à la discussion

Une nouvelle version pour test.

le dossier destination doit toujours être sur le bureau


Le script te demande de choisir le dossier à trier

puis de choisir le nom du dossier 2

puis le nom du dossier 3

puis le nom du dossier 4


Ces noms étant fonction du dossier que tu choisis de trier

Le nom du dossier 1 étant le nom du pictos il sera mis automatiquement.


Tu peux ensuite essayer avec un 2ieme dossier, Il devrait venir mettre les fichiers dans les dossiers existant ou en créer si nécessaire.


le script duplique les fichiers contenus dans le dossier choisi, mais pas ses sous dossier.

S'il existe des sous dossiers tu me le dira, je modifierai pour les prendre en compte.

Si les test sont concluant en fera la modification pour déplacer au lieu de dupliquer.


[CODE]tell application "Finder"

  

    set chemin to choose folder with prompt "Sélectionnez le dossier contenant les fichiers à trier"

  

    repeat

        set nameList to {"Full", "Simple"}

        set choix to (choose from list the nameList with prompt "Sélectionner le nom du dossier 2 : " with title "Choix") as string

        if choix is "false" then quit --exit repeat -- Bouton Annuler

        if choix is "Full" then

            set dossier2 to "Full"

            exit repeat

        else if choix is "Simple" then

            set dossier2 to "Simple"

            exit repeat

        end if

    end repeat

  

    repeat

        set nameList to {"Fond", "Fond avec nom", "Encadré", "Encadré avec nom", "Seul"}

        set choix to (choose from list the nameList with prompt "Sélectionner le nom du dossier 3 : " with title "Choix") as string

        if choix is "false" then quit --exit repeat -- Bouton Annuler

        if choix is "Fond" then

            set dossier3 to "Fond"

            exit repeat

        else if choix is "Fond avec nom" then

            set dossier3 to "Fond avec nom"

            exit repeat

        else if choix is "Encadré" then

            set dossier3 to "Encadré"

            exit repeat

        else if choix is "Encadré avec nom" then

            set dossier3 to "Encadré avec nom"

            exit repeat

        else if choix is "Seul" then

            display dialog "Seul"

        end if

    end repeat

  

    repeat

        set nameList to {"CMNJ", "RVB", "Pantone", "Blanc"}

        set choix to (choose from list the nameList with prompt "Sélectionner le nom du dossier 4 : " with title "Choix") as string

        if choix is "false" then quit --exit repeat -- Bouton Annuler

        if choix is "CMNJ" then

            set dossier4 to "CMJN"

            exit repeat

        else if choix is "RVB" then

            set dossier4 to "RVB"

            exit repeat

        else if choix is "Pantone" then

            set dossier4 to "Pantone"

            exit repeat

        else if choix is "Blanc" then

            set dossier4 to "Blanc"

            exit repeat

        end if

    end repeat

  

  

    set les_fichiers to files of chemin

  

    repeat with chaque_fichier in les_fichiers

      

        set nom to name of chaque_fichier --récupère le nom du fichier

        set sauv to AppleScript's text item delimiters --sauvegarder la variable delimiteur

        set AppleScript's text item delimiters to {"."}

        set lextension to name extension of chaque_fichier -- récupère l'entension

        set AppleScript's text item delimiters to sauv --restaurer la variable delimiteur

      

        set x to characters 1 thru ((offset of "_" in nom) - 1) of nom as string

      

        set chemin to (path to desktop folder) & "destination:" as string

      

        set chemindosdest to chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" & lextension

        set dossierdest to chemin & x

      

        if not (exists dossierdest) then

            make new folder at chemin with properties {name:x}

            make new folder at chemin & x with properties {name:dossier2}

            make new folder at chemin & x & ":" & dossier2 with properties {name:dossier3}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 with properties {name:dossier4}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"eps"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"jpg"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"png"}

        else if not (exists (chemin & x & ":" & dossier2)) then

            make new folder at chemin & x with properties {name:dossier2}

            make new folder at chemin & x & ":" & dossier2 with properties {name:dossier3}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 with properties {name:dossier4}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"eps"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"jpg"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"png"}

        else if not (exists (chemin & x & ":" & dossier2 & ":" & dossier3)) then

            make new folder at chemin & x & ":" & dossier2 with properties {name:dossier3}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 with properties {name:dossier4}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"eps"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"jpg"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"png"}

        else if not (exists (chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4)) then

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 with properties {name:dossier4}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"eps"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"jpg"}

            make new folder at chemin & x & ":" & dossier2 & ":" & dossier3 & ":" & dossier4 & ":" with properties {name:"png"}

        end if

      

        set aa to chaque_fichier as string

      

        duplicate chaque_fichier to chemindosdest

        --move chaque_fichier to dossierdest

    end repeat

  

  

end tell



tell application "Finder"

    (display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})

end tell[/CODE]