By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

AutoIt FileRecycle Function

Reference on the FileRecycle AutoIt Function. Explains its use, and shows useful examples.

Edited: 2015-02-13 00:10

The AutoIt FileRecycle Function is used to send files to the Recycle Bin in the operating system. The function can also be used to send entire directories to the Recycle Bin, leaving nothing behind – this behavior is a little different than that of FileDelete, in that FileDelete only touches the content of the directory, leaving behind a empty folder.

You can use FileRecycleEmpty to empty the Recycle Bin if IE4+ is available on the system.

FileRecycle will only move the files to the Recycle Bin – if you want to delete the file directly, use FileDelete instead.

Returns 1 on success, and 0 on failure (can indicate that the file is in use).

AutoIt FileRecycle Example

The below example uses the (*.*) wildcard, which will match all files in the given directory.

FileRecycle("ScriptTemp\*.*")

And the following example will recycle the whole directory – including its contents – leaving nothing behind.

FileRecycle("ScriptTemp\")

You can also use Absolute Paths, this is demonstrated in the final example below.

FileRecycle("c:\ScriptTemp\")