Extracted file name truncator to a function