---
title: "removeOtherVersionsOfItem(at:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsfileversion/removeotherversionsofitem(at:)"
---

# removeOtherVersionsOfItem(at:)

Removes all versions of a file, except the current one, from the version store.

## Declaration

```swift
class func removeOtherVersionsOfItem(at url: URL) throws
```

## Parameters

- `url`: The file whose older versions you want to delete. If the file at this URL does not exist, a new file is created at the location.

## Discussion

Discussion This method removes all versions except the current one from the version store, freeing up the associated storage space. You should always remove file versions as part of a coordinated write operation to a file. In other words, always call this method from a block passed to a file coordinator object to initiate a write operation. Doing so ensures that no other processes are operating on the file while you remove the version information. If successful, subsequent requests for the versions of the file reflect that only the current version is available. You can use this method to free up disk space by removing versions that are no longer needed. note: In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Replacing and Deleting Versions

- [replaceItem(at:options:)](foundation/nsfileversion/replaceitem(at:options:).md)
- [remove()](foundation/nsfileversion/remove().md)
