Fix bug in shorten_filenames_encoder which now truncates to a specified N levels of pathname nesting; add unit test