import Foundation let a = URL(fileURLWithPath: "a.swift") let dir = a.deletingLastPathComponent() print("dir='\(dir.path)'") let b = dir.appendingPathComponent("b.swift") print("b='\(b.path)'")