-1

e.g. a function should return:

  • stackpath = "config/openvpn/openvpn02.json"

for stackname = "openvpn02".

How would I search "openvpn02.json" in the config directory?

Dennis
  • 2,716
  • 4
  • 28
  • 42

1 Answers1

1

like this

import os

to_search = "filename"

for dirpath, dirnames, filenames in os.walk("."):
    for filename in [f for f in filenames if "".join(f.split(".")[:-1])==to_search]:
        print os.path.join(dirpath, filename)
Liam
  • 5,218
  • 3
  • 32
  • 49