ssh_dir_batch_delete_files
Recursively delete files matching a glob pattern under a remote directory via SSH. Preview deletions by default for safety.
Instructions
Recursively find and delete files matching a filename glob pattern (same pattern
syntax as ssh_dir_search_glob, e.g. *.tmp) under a directory. dry_run
DEFAULTS TO True - calling this with no arguments other than path/pattern
only PREVIEWS which files would be deleted and deletes NOTHING; you must
explicitly pass dry_run=False to actually delete.
On a 'linux'/'flex' connection with a BusyBox-style xargs that doesn't
support -0 (check ssh_conn_connect/ssh_conn_host_info's capabilities),
this raises a clear error instead of running. Fallback: ssh_cmd_run with
find <path> -name '<pattern>' -exec rm -f {} + instead - portable, and
still safe with spaces in filenames.
Returns:
{'status': 'success'/'error', 'deleted_files': [str, ...] (matching file paths that were/would be deleted)}, plus 'dry_run': True ONLY when this
was a preview (check for this key to tell a preview apart from a real
deletion) and 'error' (string) on failure. Note the key is deleted_files
here, vs. deleted_items on ssh_dir_delete.
Long-running calls: if this takes longer than the server's wait cap (default 50s), it
returns {"status": "in_progress", "handle_id": ...} instead of the result - the work keeps
running. Get the result by polling ssh_cmd_check_status(handle_id=...), which returns this
tool's normal response once finished. Do not call it again meanwhile. Only one such
operation runs at a time; another one started meanwhile fails with a 'busy' error.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Base directory to search in | |
| dry_run | No | Preview deletion without actually deleting | |
| pattern | Yes | File pattern to match for deletion (e.g. *.tmp) | |
| use_sudo | No | Use sudo for the operation |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||