Nim Programming Cookbook // Directories

Directory Listing

Problem: list of files in a directory

Print a list of files in a directory matching a pattern.

Solution

Print the list of all .nim files in this directory

import os

for f in walkFiles("*.nim"):
  echo(f)

You can even search in child directories.

for f in walkFiles("/tmp/*/*"):
  echo(f)