Skip to content

Instantly share code, notes, and snippets.

@NicHub
Last active January 12, 2020 08:31
Show Gist options
  • Save NicHub/9dc7bae12f79dc9fe07bbe8e8ed94508 to your computer and use it in GitHub Desktop.
Save NicHub/9dc7bae12f79dc9fe07bbe8e8ed94508 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pathlib2
def recursive_file_search_with_pattern(root_path, pattern):
pl_dir = pathlib2.Path(root_path)
file_list = [path.resolve()
for path in sorted(pl_dir.rglob(pattern))
if path.is_file()]
return file_list
if __name__ == "__main__":
root_path = "~/"
pattern = '*.nmea'
file_list = recursive_file_search_with_pattern(root_path, pattern)
for cnt, file_ in enumerate(file_list):
print(f"{(cnt + 1):3}. {file_}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment