Skip to content

Instantly share code, notes, and snippets.

@wcDogg
Last active January 21, 2023 06:28
Show Gist options
  • Save wcDogg/04519e00fa28996750885219054237ef to your computer and use it in GitHub Desktop.
Save wcDogg/04519e00fa28996750885219054237ef to your computer and use it in GitHub Desktop.
An OS-agnostic way to list files in a directory using Python.

Python: List Files in a Directory

from os import listdir
from pathlib import Path

dir_start: Path = "D:\Media\Movies"

for f in listdir(dir_start):
  print(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment