# DirectoryLoader

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/document_loaders/directory/DirectoryLoader)

Load from a directory.

## Signature

```python
DirectoryLoader(
    self,
    path: str,
    glob: Union[List[str], Tuple[str], str] = '**/[!.]*',
    silent_errors: bool = False,
    load_hidden: bool = False,
    loader_cls: FILE_LOADER_TYPE = UnstructuredFileLoader,
    loader_kwargs: Union[dict, None] = None,
    recursive: bool = False,
    show_progress: bool = False,
    use_multithreading: bool = False,
    max_concurrency: int = 4,
    *,
    exclude: Union[Sequence[str], str] = (),
    sample_size: int = 0,
    randomize_sample: bool = False,
    sample_seed: Union[int, None] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `path` | `str` | Yes | Path to directory. |
| `glob` | `Union[List[str], Tuple[str], str]` | No | A glob pattern or list of glob patterns to use to find files. Defaults to "**/[!.]*" (all files except hidden). (default: `'**/[!.]*'`) |
| `exclude` | `Union[Sequence[str], str]` | No | A pattern or list of patterns to exclude from results. Use glob syntax. (default: `()`) |
| `silent_errors` | `bool` | No | Whether to silently ignore errors. Defaults to False. (default: `False`) |
| `load_hidden` | `bool` | No | Whether to load hidden files. Defaults to False. (default: `False`) |
| `loader_cls` | `FILE_LOADER_TYPE` | No | Loader class to use for loading files. Defaults to UnstructuredFileLoader. (default: `UnstructuredFileLoader`) |
| `loader_kwargs` | `Union[dict, None]` | No | Keyword arguments to pass to loader_cls. Defaults to None. (default: `None`) |
| `recursive` | `bool` | No | Whether to recursively search for files. Defaults to False. (default: `False`) |
| `show_progress` | `bool` | No | Whether to show a progress bar. Defaults to False. (default: `False`) |
| `use_multithreading` | `bool` | No | Whether to use multithreading. Defaults to False. (default: `False`) |
| `max_concurrency` | `int` | No | The maximum number of threads to use. Defaults to 4. (default: `4`) |
| `sample_size` | `int` | No | The maximum number of files you would like to load from the directory. (default: `0`) |
| `randomize_sample` | `bool` | No | Shuffle the files to get a random sample. (default: `False`) |
| `sample_seed` | `Union[int, None]` | No | set the seed of the random shuffle for reproducibility. (default: `None`) |

## Extends

- `BaseLoader`

## Constructors

```python
__init__(
    self,
    path: str,
    glob: Union[List[str], Tuple[str], str] = '**/[!.]*',
    silent_errors: bool = False,
    load_hidden: bool = False,
    loader_cls: FILE_LOADER_TYPE = UnstructuredFileLoader,
    loader_kwargs: Union[dict, None] = None,
    recursive: bool = False,
    show_progress: bool = False,
    use_multithreading: bool = False,
    max_concurrency: int = 4,
    *,
    exclude: Union[Sequence[str], str] = (),
    sample_size: int = 0,
    randomize_sample: bool = False,
    sample_seed: Union[int, None] = None,
)
```

| Name | Type |
|------|------|
| `path` | `str` |
| `glob` | `Union[List[str], Tuple[str], str]` |
| `silent_errors` | `bool` |
| `load_hidden` | `bool` |
| `loader_cls` | `FILE_LOADER_TYPE` |
| `loader_kwargs` | `Union[dict, None]` |
| `recursive` | `bool` |
| `show_progress` | `bool` |
| `use_multithreading` | `bool` |
| `max_concurrency` | `int` |
| `exclude` | `Union[Sequence[str], str]` |
| `sample_size` | `int` |
| `randomize_sample` | `bool` |
| `sample_seed` | `Union[int, None]` |


## Properties

- `path`
- `glob`
- `exclude`
- `load_hidden`
- `loader_cls`
- `loader_kwargs`
- `silent_errors`
- `recursive`
- `show_progress`
- `use_multithreading`
- `max_concurrency`
- `sample_size`
- `randomize_sample`
- `sample_seed`

## Methods

- [`load()`](https://reference.langchain.com/python/langchain-community/document_loaders/directory/DirectoryLoader/load)
- [`lazy_load()`](https://reference.langchain.com/python/langchain-community/document_loaders/directory/DirectoryLoader/lazy_load)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/document_loaders/directory.py#L29)