---
title: "recycle(_:completionHandler:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsworkspace/recycle(_:completionhandler:)"
---

# recycle(_:completionHandler:)

Moves the specified URLs to the trash in the same manner as the Finder.

## Declaration

```swift
func recycle(_ URLs: [URL], completionHandler handler: (@Sendable ([URL : URL], (any Error)?) -> Void)? = nil)
```

```swift
func recycle(_ URLs: [URL]) async throws -> [URL : URL]
```

## Parameters

- `URLs`: An array of doc://com.apple.documentation/documentation/Foundation/NSURL objects representing the files to move to the trash. This parameter must not be nil
- `handler`: The completion handler block object to call when the operation completes. You may specify nil for this parameter. If this parameter is not nil, you must call the doc://com.apple.appkit/documentation/AppKit/NSWorkspace/recycle(_:completionHandler:) method from a block running on an active dispatch queue; your completion handler block is subsequently executed on the same dispatch queue. The block takes two arguments:

## Discussion

Discussion This method may cause a progress indicator, or other user interface element, to be shown by the Finder. In macOS 10.6, this method requires the app to run the main run loop in a common mode to facilitate the display of any user interface elements. You can safely call this method from any thread of your app.

## See Also

### Manipulating Files

- [duplicate(_:completionHandler:)](appkit/nsworkspace/duplicate(_:completionhandler:).md)
- [activateFileViewerSelecting(_:)](appkit/nsworkspace/activatefileviewerselecting(_:).md)
- [selectFile(_:inFileViewerRootedAtPath:)](appkit/nsworkspace/selectfile(_:infileviewerrootedatpath:).md)
