Erm... If your filenames are all /some/prefix/dirname/xxxYYYY-MM-DD-hh-mm-ss..., as in the example, then just doing a standard (ASCII-ordered) sort will give you the filenames in each directory in timestamp order, provided that (again, as in your example data) all files within the same dirname have the same xxx.