Function to separate parts of filename