Last active
November 25, 2021 04:39
-
-
Save dmentipl/f02badae3122305406865ceb30e6c00e to your computer and use it in GitHub Desktop.
Get the last .h5 snap in a dir (or list of dirs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
from pathlib import Path | |
def main(): | |
parser = argparse.ArgumentParser(description='Last snap') | |
parser.add_argument('dirs', type=str, nargs='+', help='Input dirs for snaps') | |
args = parser.parse_args() | |
for d in args.dirs: | |
_d = Path(d) | |
if _d.exists(): | |
try: | |
lastsnap = sorted(_d.glob('*.h5'))[-1].name | |
print(f'{d}/{lastsnap}') | |
except IndexError: | |
print(f'{d} contains no .h5 files') | |
else: | |
print(f'{d} does not exist') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment