Rewritten to be independent of the number of logfiles being in the folder