---
layout: default
---

# DirectoryLoader

<v-clicks>

Carga todos los archivos de un directorio, mapeando extensiones a loaders

```typescript
import { DirectoryLoader } from
  "@langchain/community/document_loaders/fs/directory";
import { PDFLoader } from
  "@langchain/community/document_loaders/fs/pdf";
import { TextLoader } from
  "@langchain/community/document_loaders/fs/text";
import { CSVLoader } from
  "@langchain/community/document_loaders/fs/csv";

const loader = new DirectoryLoader("./documentos/", {
  ".pdf": (path) => new PDFLoader(path),
  ".txt": (path) => new TextLoader(path),
  ".md": (path) => new TextLoader(path),
  ".csv": (path) => new CSVLoader(path),
});

const docs = await loader.load();
console.log(`Cargados ${docs.length} documentos`);
```

<div class="mt-4 p-4 bg-blue-500/10 rounded">
💡 Muy útil para indexar carpetas enteras de documentación de una sola vez
</div>

</v-clicks>
