Workflow n8n

Automatisation de gestion de fichiers avec n8n : organisation simplifiée

  • Ce workflow n8n est conçu pour automatiser la gestion de fichiers, permettant aux utilisateurs de mieux organiser leurs documents et dossiers. Dans un contexte professionnel où la gestion des fichiers peut rapidement devenir chaotique, ce workflow offre une solution efficace pour trier et déplacer des fichiers automatiquement. Il est particulièrement utile pour les équipes qui manipulent de grandes quantités de données, comme les agences de communication ou les départements de marketing.
  • Le processus commence par un déclencheur de type 'Local File Trigger', qui surveille un dossier spécifique pour tout changement. Lorsque des fichiers sont ajoutés, le workflow exécute une commande pour récupérer ces fichiers et les convertir en tableau. Ensuite, un modèle de chat Mistral Cloud est utilisé pour analyser le contenu des fichiers, suivi par un parseur de sortie structuré qui organise les informations selon un schéma prédéfini.
  • Les fichiers sont ensuite déplacés dans des dossiers appropriés grâce à une autre commande d'exécution. Des notes autocollantes sont créées à chaque étape pour fournir un retour visuel sur le processus. Ce workflow n8n permet non seulement de gagner du temps, mais aussi de réduire les erreurs humaines dans la gestion des fichiers, offrant ainsi une valeur ajoutée significative pour les entreprises. En automatisant ces tâches répétitives, les équipes peuvent se concentrer sur des activités à plus forte valeur ajoutée.
Tags clés :automatisationgestion de fichiersn8nagence automatisationworkflow
Catégorie: Local File Trigger · Tags: automatisation, gestion de fichiers, n8n, agence automatisation, workflow0

Workflow n8n gestion de fichiers, agence automatisation : vue d'ensemble

Schéma des nœuds et connexions de ce workflow n8n, généré à partir du JSON n8n.

Workflow n8n gestion de fichiers, agence automatisation : détail des nœuds

  • Local File Trigger

    Déclenche un workflow lorsque des fichiers locaux sont créés ou modifiés.

  • Get Files and Folders

    Exécute une commande pour récupérer des fichiers et des dossiers.

  • Files and Folders to Array

    Transforme les fichiers et dossiers récupérés en un tableau.

  • Mistral Cloud Chat Model

    Utilise le modèle de chat Mistral Cloud pour générer des réponses.

  • Structured Output Parser

    Parse les résultats en sortie selon un schéma structuré défini.

  • Set Variables

    Définit des variables à utiliser dans le workflow.

  • Move Files into Folders

    Déplace des fichiers dans des dossiers spécifiés.

  • Sticky Note

    Crée une note autocollante avec un contenu et des dimensions spécifiés.

  • Sticky Note1

    Crée une seconde note autocollante avec des paramètres de couleur et de taille.

  • If Has Target Files...

    Évalue une condition pour vérifier la présence de fichiers cibles.

  • Sticky Note2

    Ajoute une troisième note autocollante avec des spécifications de couleur et de taille.

  • Get Suggestions to List

    Divise les suggestions en une liste selon un champ spécifié.

  • Sticky Note3

    Crée une quatrième note autocollante avec des dimensions et un contenu donné.

  • Sticky Note4

    Crée une cinquième note autocollante avec un contenu et des dimensions définies.

  • Sticky Note5

    Ajoute une sixième note autocollante avec des spécifications de couleur et de taille.

  • AI File Manager

    Gère les fichiers à l'aide d'un modèle de langage AI pour des interactions avancées.

Inscris-toi pour voir l'intégralité du workflow

Inscription gratuite

S'inscrire gratuitementBesoin d'aide ?
{
  "meta": {
    "instanceId": "26ba763460b97c249b82942b23b6384876dfeb9327513332e743c5f6219c2b8e"
  },
  "nodes": [
    {
      "id": "c92e3d01-4385-4e99-a9a7-77279b3d9cb3",
      "name": "Local File Trigger",
      "type": "n8n-nodes-base.localFileTrigger",
      "position": [
        720,
        120
      ],
      "parameters": {
        "path": "/home/node/host_mount/shared_drive",
        "events": [
          "add"
        ],
        "options": {
          "awaitWriteFinish": true
        },
        "triggerOn": "folder"
      },
      "typeVersion": 1
    },
    {
      "id": "a08f5acc-ee46-49e7-be4d-99edc95ab41f",
      "name": "Get Files and Folders",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        1200,
        120
      ],
      "parameters": {
        "command": "=ls -p {{ $json.directory }} | grep -v / || true; \\\necho \"===\"; \\\nls -p {{ $json.directory }} | grep / || true;"
      },
      "typeVersion": 1
    },
    {
      "id": "f3ab100a-986d-49bc-aeb5-979f16b2fd46",
      "name": "Files and Folders to Array",
      "type": "n8n-nodes-base.set",
      "position": [
        1380,
        120
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ad893795-cae8-4418-99e0-2c68126337d3",
              "name": "files",
              "type": "array",
              "value": "={{ $json.stdout.split('===')[0].split('\\n').filter(item => !item.endsWith('Zone.Identifier')).compact() }}"
            },
            {
              "id": "0e7e8571-6b86-481d-a20c-3a7c621c562f",
              "name": "folders",
              "type": "array",
              "value": "={{ $json.stdout.split('===')[1].split('\\n').compact() }}"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "56c4a8b4-c5b0-4e2f-806b-fef5fb5260b5",
      "name": "Mistral Cloud Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
      "position": [
        1860,
        240
      ],
      "parameters": {
        "model": "mistral-small-2402",
        "options": {}
      },
      "credentials": {
        "mistralCloudApi": {
          "id": "EIl2QxhXAS9Hkg37",
          "name": "Mistral Cloud account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0d586481-904d-4fbd-9b53-77bc2faf08dd",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2040,
        240
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"array\",\n\t\"items\": {\n    \t\"type\": \"object\",\n        \"properties\": {\n          \"folder\": { \"type\": \"string\" },\n          \"files\": {\n            \"type\": \"array\",\n            \"items\": { \"type\": \"string\" }\n          }\n\t\t}\n    }\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "86025668-aac9-49a2-92ff-ce15df16488c",
      "name": "Set Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        940,
        120
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "35ea70c4-8669-4975-a68d-bbaa094713c0",
              "name": "directory",
              "type": "string",
              "value": "={{ $('Local File Trigger').params.path }}"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "457bfd30-5cca-417a-88d3-666afe567fd5",
      "name": "Move Files into Folders",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        2560,
        140
      ],
      "parameters": {
        "command": "=directory=\"{{ $('Set Variables').item.json.directory }}\"\nsubdirectory=\"$directory/{{ $json.folder }}\";\nfile_list=\"{{ $json.files.join(' ') }}\";\n\n# create subdirectory if not exists\nmkdir -p $subdirectory;\n\n# for each suggestion, move the file into the subdirectory.\n# If the file in the subdirectory exists, then we'll rename the current file by adding a small random string to the end of the filename.\nfor filename in $file_list; do\n    if [ -e \"$subdirectory/$filename\" ]; then\n        mv \"$directory/$filename-$RANDOM\" -t $subdirectory;\n    else\n        mv \"$directory/$filename\" -t $subdirectory;\n    fi\ndone",
        "executeOnce": false
      },
      "typeVersion": 1
    },
    {
      "id": "e9a610bf-b2ae-4b98-870a-2e63790a3b5f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        635.4233386400999,
        -161.84747801133517
      ],
      "parameters": {
        "color": 7,
        "width": 483.7926535356806,
        "height": 501.2939838391483,
        "content": "## Step 1. Select the target folder\n[Read more about local file trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.localfiletrigger)\n\nIn this workflow, we'll monitor a specific folder on disk that n8n has access to. Since we're using docker, we can either use the n8n volume or mount a folder from the host machine.\n\nThe local file trigger is useful to execute the workflow whenever changes are made to our target folder."
      },
      "typeVersion": 1
    },
    {
      "id": "c8961322-a6da-4fc0-a46d-6119c5eac2b0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        -54.28207683557787
      ],
      "parameters": {
        "color": 7,
        "width": 583.2857596176409,
        "height": 391.527066537946,
        "content": "## Step 2. Identify files that need to be organised\n[Read more about Execute Command node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executecommand)\n\nFor all Files in the root level of our selected target folder, we want  them to be sorted and moved into categorised subdirectories. In this step, we'll use linux commands to get a list of files and folders currently present in the target folder."
      },
      "typeVersion": 1
    },
    {
      "id": "6e31b2d1-288c-479b-8dd8-a171ecd03dea",
      "name": "If Has Target Files...",
      "type": "n8n-nodes-base.if",
      "position": [
        1560,
        120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9be5a175-e7aa-4d68-9ddc-8b43b43e2d37",
              "operator": {
                "type": "array",
                "operation": "lengthGte",
                "rightType": "number"
              },
              "leftValue": "={{ $json.files }}",
              "rightValue": "={{ 1 }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "07fd70ca-9126-4846-a2b0-4f3a8fc5eb69",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        -107.13740439436373
      ],
      "parameters": {
        "color": 7,
        "width": 631.2649908751414,
        "height": 506.8242545618477,
        "content": "## Step 3. Using Mistral AI to organise our target folder\n[Read more about Mistral AI](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatmistralcloud)\n\nUsing Mistral AI as our AI file manager, it can help us suggest which files go into which categorised subdirectory. If the subdirectory doesn't exist, Mistral can also suggest one to be created."
      },
      "typeVersion": 1
    },
    {
      "id": "2ca9a56c-ed1b-4f16-b207-7229c8d90b76",
      "name": "Get Suggestions to List",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2200,
        80
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "29d425df-e513-429a-802f-02ad3ad86344",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2420,
        -62.701160902940615
      ],
      "parameters": {
        "color": 7,
        "width": 401.0065589583014,
        "height": 374.8503908496576,
        "content": "## Step 4. Move the files into subdirectories\n[Read more about Execute Command node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executecommand)\n\nFor this step, we'll use the execute command node to execute a shellscript to move the files into their respective subdirectories."
      },
      "typeVersion": 1
    },
    {
      "id": "a2ee79ea-6b0d-46c0-876f-8cfe12130a62",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -160
      ],
      "parameters": {
        "width": 372.51107341403605,
        "height": 422.70324544339167,
        "content": "## Try It Out!\n### This workflow does the following:\n* Monitors a target folder for changes using the local file trigger\n* identifies all files and subdirectories in the target folder and passes this to Mistral AI\n* Mistral AI suggests where to move top level files into which subdirectories. It can also suggest subdirectories tp create if none are suitable.\n* Finally, we take the AI's suggestions are perform the move operations using the execute command node.\n\n### Need Help?\nJoin the [Discord](https://discord.com/invite/XPKeKXeB7d) or ask in the [Forum](https://community.n8n.io/)!\n\nHappy Hacking!"
      },
      "typeVersion": 1
    },
    {
      "id": "a0db31b1-10e2-40bb-9ec6-b91569bf1072",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        174.82571715185748,
        280
      ],
      "parameters": {
        "color": 3,
        "width": 438.23697639546396,
        "height": 97.88076166036412,
        "content": "### 🚨 Warning! Potential destructive operations ahead!\nThis workflow manipulates the filesystem. Always make backups of your files before running local workflows."
      },
      "typeVersion": 1
    },
    {
      "id": "c932813c-913c-47bd-a4ba-79056bc6dfd7",
      "name": "AI File Manager",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1860,
        80
      ],
      "parameters": {
        "text": "=Here is the list of current files in the directory:\n{{ $json.files.map(file => `* ${file}`).join('\\n') }}\n\nHere is the list of current folders in the directory:\n{{ $json.folders.length ? $json.folders.map(item => `* ${item}`).join('\\n') : 'There are currently no directories' }}\n\nGroup the current files using the filename as a hint and decide which of the current folders should they be moved to. If there are no current folders, then suggest a folder to be created.\n\nIf you can't decide which folder to put the file in, the file should be moved to the misc folder.",
        "messages": {
          "messageValues": [
            {
              "message": "You manage a linux directory on behalf of the user."
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.4
    }
  ],
  "pinData": {},
  "connections": {
    "Set Variables": {
      "main": [
        [
          {
            "node": "Get Files and Folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI File Manager": {
      "main": [
        [
          {
            "node": "Get Suggestions to List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Local File Trigger": {
      "main": [
        [
          {
            "node": "Set Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Files and Folders": {
      "main": [
        [
          {
            "node": "Files and Folders to Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Has Target Files...": {
      "main": [
        [
          {
            "node": "AI File Manager",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Suggestions to List": {
      "main": [
        [
          {
            "node": "Move Files into Folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Cloud Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI File Manager",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI File Manager",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Files and Folders to Array": {
      "main": [
        [
          {
            "node": "If Has Target Files...",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Workflow n8n gestion de fichiers, agence automatisation : pour qui est ce workflow ?

Ce workflow s'adresse aux équipes de gestion de données, aux agences de communication et aux départements marketing qui cherchent à optimiser leur gestion de fichiers. Il est conçu pour des utilisateurs ayant un niveau technique intermédiaire et souhaitant automatiser des tâches répétitives.

Workflow n8n gestion de fichiers, agence automatisation : problème résolu

Ce workflow résout le problème de la gestion désordonnée des fichiers en automatisant leur organisation. Il élimine les frustrations liées à la recherche manuelle de documents et réduit le risque d'erreurs lors du déplacement de fichiers. Après mise en place, les utilisateurs bénéficient d'une gestion de fichiers plus fluide et d'un gain de temps significatif, leur permettant de se concentrer sur des tâches plus stratégiques.

Workflow n8n gestion de fichiers, agence automatisation : étapes du workflow

Étape 1 : Le workflow commence par un déclencheur de type 'Local File Trigger' qui détecte les nouveaux fichiers.

  • Étape 1 : Il exécute une commande pour récupérer ces fichiers et les convertit en tableau.
  • Étape 2 : Ensuite, le modèle de chat Mistral Cloud analyse le contenu des fichiers.
  • Étape 3 : Les résultats sont ensuite traités par un parseur de sortie structuré.
  • Étape 4 : Les fichiers sont déplacés dans des dossiers appropriés via une commande d'exécution.
  • Étape 5 : Des notes autocollantes sont créées pour fournir un retour visuel à chaque étape.

Workflow n8n gestion de fichiers, agence automatisation : guide de personnalisation

Pour personnaliser ce workflow, vous pouvez modifier le chemin du dossier surveillé dans le déclencheur 'Local File Trigger'. Adaptez également les commandes d'exécution pour répondre à vos besoins spécifiques en matière de gestion de fichiers. Si vous souhaitez intégrer d'autres outils, vous pouvez ajouter des nœuds supplémentaires après le parseur de sortie structuré. Assurez-vous de sécuriser le flux en configurant les permissions d'accès aux fichiers et en surveillant les logs d'exécution pour détecter d'éventuelles erreurs.