From the copyItemAtPath(...)
documentation:
dstPath
The path at which to place the copy ofsrcPath
. This path must
include the name of the file or directory in its new location. …
You have to append the file name to the destination directory for the
copyItemAtPath()
call (code updated for Swift 3 and later)
let srcURL = URL(fileURLWithPath: fullElementPath)
let destURL = URL(fileURLWithPath: newMTSFolder).appendingPathComponent(srcURL.lastPathComponent)
do {
try FileManager.default.copyItem(at: srcURL, to: destURL)
} catch {
print("copy failed:", error.localizedDescription)
}