# MX\_DIRCLEAN

> [HTML Version](mx_dirclean.htm)

_Reviewed and revised April 2024_

**xcall MIAMEX, MX\_DIRCLEAN, dirspec, loc'rem, status \{,wildspec, flags, timelimit, bytes\}**

MX\_DIRCLEAN (204) scans a specified directory, counting and/or deleting files based on various filter attributes.

This function has both a [subroutine and a print tab implementation](subroutine-print-pairs.md).

**Parameters**

_dirspec_  ([String](string.md))  \[in\]

target directory, in any reasonable format; may include %env% variables

_loc'rem _ ([String](string.md))  \[in\]

L)ocal interprets _dirspec_ as local to application server; R)emote or C)lient interprets _direspec_ as an ATE remote spec

_status_  ([Signed Int](integer-signed.md))  \[out\]

returns the number of files matched or deleted; negative values indicate errors

_wildspec_  ([String](string.md))  \[in\]

optional wildcard spec (default is \*.\*)

_flags_  ([Bitmap](bitmap.md) 8)  \[in\]

zero or more of the following bit flags:

| | |
|------|------|
| **Value** | **Meaning / Effect ** |
| \&h0001 | only files with mtime < timelimit |
| \&h0002 | only files with timestamp < timelimit |
| \&h0004 | only files > bytelimit |
| \&h0008 | only files < bytelimit |
| \&h0010 | no action (just count matching files, bytes; else delete) |


_timelimit_  (T\_FILETIME or B6)  \[in\]

time threshold (seconds since the 'epoch') if flags \&h0001 or \&h0002 are specified. Note that B4 will work up to 2038, but beyond that the value will overflow 32 bits.

_bytes _ ([Num](num.md))  \[in/out\]

on input, sets file size threshhold (if flags \&h0004 or \&h0008); on output returns number of bytes in the matching files

**See Also**

•	[AG\_DIRCLEAN](ag_webcache.md)

**History**

2023 August, A-Shell 6.5.1740:  Routine added to A-Shell.