Main Content

recycle

Set option to move deleted files to recycle folder

Description

status = recycle returns the current state for recycling files you remove using the delete function. When status is off, the delete function permanently removes the files. When status is on, delete moves the files to a different location, which varies by platform:

  • Windows® — Recycle bin.

  • macOS — Trash.

  • Linux® platforms — Subfolder with the prefix MATLAB_Files_ in the system temporary folder, as returned by the tempdir function.

Note

On macOS, the recycle option is not applied to files deleted from network drives.

example

previousState = recycle(state) sets the recycle option for MATLAB® to the specified state, either on or off. The returned previousState value is the recycle state before running the statement.

example

Examples

collapse all

Start from a state where file recycling is off. Verify the current recycle state.

state = recycle
state =

off

Turn on file recycling. Then, delete an existing file and move it to the recycle bin or temporary folder.

recycle('on');
delete('myfile.txt')

Input Arguments

collapse all

State of the recycle option, specified as 'on' or 'off'.

Alternative Functionality

You also can set the recycle option for MATLAB using preferences. To do so, go to the Home tab and in the Environment section, click Preferences. Select MATLAB > General. Then, in the Deleting files section, select from the available options. By default, the Delete permanently option is selected.

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced before R2006a

See Also

| | | |