Swift 3.0
let sourcePath = NSURL(string: fnName)?.pathExtension let pathPrefix = fnName.replacingOccurrences(of: "." + sourcePath!, with: "")