class torchdata.datapipes.iter.FileLister(root: Union[str, Sequence[str], IterDataPipe] = '.', masks: Union[str, List[str]] = '', *, recursive: bool = False, abspath: bool = False, non_deterministic: bool = False, length: int = - 1)

Given path(s) to the root directory, yields file pathname(s) (path + filename) of files within the root directory. Multiple root directories can be provided (functional name: list_files).

  • root – Root directory or a sequence of root directories

  • masks – Unix style filter string or string list for filtering file name(s)

  • recursive – Whether to return pathname from nested directories or not

  • abspath – Whether to return relative pathname or absolute pathname

  • non_deterministic – Whether to return pathname in sorted order or not. If False, the results yielded from each root directory will be sorted

  • length – Nominal length of the datapipe


>>> # xdoctest: +SKIP
>>> from torchdata.datapipes.iter import FileLister
>>> dp = FileLister(root=".", recursive=True)
>>> list(dp)
['', './data/data.tar']


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources