Main Content


Set option to move deleted files to recycle folder



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, deleted files move to a different location. For details, see the Tips section.


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


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.


collapse all

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

state = recycle
state =


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


Input Arguments

collapse all

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


  • The location for storing recycled files varies by platform, as follows:

    • Windows® platforms — Recycle bin.

    • Mac platforms — Trash.

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

  • The general preference for Deleting files sets the state of the recycle function at startup. When you change the preference, MATLAB changes the state of recycle. When you change the state of recycle, MATLAB also updates the Deleting files preference.

Version History

Introduced before R2006a