<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.5.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSFileManager/movePath:toPath:handler:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)movePath:toPath:handler:"
  },
  "title" : "movePath:toPath:handler:"
}
-->

# movePath:toPath:handler:

Moves the directory or file specified by a given path to a different location in the file system identified by another path.

```
- (BOOL) movePath:(NSString *) src toPath:(NSString *) dest handler:(id) handler;
```

## Parameters

`src`

The path of a file or directory to move. `source` must exist.

`dest`

The path to which `source` is moved. `destination` must not yet exist. The destination path must end in a filename; there is no implicit adoption of the source filename.

`handler`

An object that responds to the callback messages <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:willProcessPath:)> and <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)>. You can specify `nil` for `handler`; if you do so and an error occurs, the method automatically returns <doc://com.apple.documentation/documentation/Swift/false>.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the move operation is successful. If the operation is not successful, but the handler method <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)> returns <doc://com.apple.documentation/documentation/Swift/true>, [`movePath:toPath:handler:`](/documentation/Foundation/NSFileManager/movePath:toPath:handler:) also returns <doc://com.apple.documentation/documentation/Swift/true>; otherwise returns <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

If `source` is a file, the method creates a file at `destination` that holds the exact contents of the original file and then deletes the original file. If `source` is a directory, [`movePath:toPath:handler:`](/documentation/Foundation/NSFileManager/movePath:toPath:handler:) creates a new directory at `destination` and recursively populates it with duplicates of the files and directories contained in `source`. It then deletes the old directory and its contents.  Symbolic links are not traversed, however links are preserved. File or directory attributes—that is, metadata such as owner and group numbers, file permissions, and modification date—are also moved.

The handler callback mechanism is similar to delegation. `NSFileManager` sends <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:willProcessPath:)> when it begins a copy, move, remove, or link operation. It sends <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/fileManager(_:shouldProceedAfterError:)> when it encounters any error in processing.

If a failure in a move operation occurs, either the preexisting path or the new path remains intact, but not both.

### Special Considerations

Because this method does not return error information, it has been deprecated as of OS X v10.5. Use [`moveItem(at:to:)`](/documentation/Foundation/FileManager/moveItem(at:to:)) instead.

## See Also

[`func linkItem(at: URL, to: URL) throws`](/documentation/Foundation/FileManager/linkItem(at:to:))

Creates a hard link between the items at the specified URLs.

[`func moveItem(atPath: String, toPath: String) throws`](/documentation/Foundation/FileManager/moveItem(atPath:toPath:))

Moves the file or directory at the specified path to a new location synchronously.

[`func copyItem(atPath: String, toPath: String) throws`](/documentation/Foundation/FileManager/copyItem(atPath:toPath:))

Copies the item at the specified path to a new location synchronously.

[`func removeItem(atPath: String) throws`](/documentation/Foundation/FileManager/removeItem(atPath:))

Removes the file or directory at the specified path.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)