Task SharePoint - Delete File
The SharePoint - Delete file(s) Task deletes the files, and optionally folders, on a SharePoint site that match a file filter, using a SharePoint Connection.
The SharePoint Tasks work with SharePoint 2010, 2013 and 2016 on premises, and with SharePoint Online.

This Task uses a SharePoint Connection; see Connection - SharePoint. When a certificate is selected in the Connection, the Task accepts any server certificate, and each run of a SharePoint Task changes TLS handling for the whole Server process.
The Main settings, Flow, On error, Conditions and TimeOut tabs are the same for every Task; see Job - Tasks.
Delete file(s): Location tab
- Connection: the SharePoint Connection to use. The button next to the list manages Connections
- Source folder: the folder or document library on the SharePoint site, as a server-relative path. The folder button next to the field opens a browser of the site
- Item mask: the names of the items to delete. "" matches any characters and "?" one character; separate several masks with ";". The default is ""
- Filter: "Files" (default), "Folders" or "All", the kind of item that matches
- Case sensitive: match Item mask with case
- Include sub folders: also search the folders under Source folder
Variables are resolved in Source folder and Item mask.
Delete file(s): Date tab
- Newer than and Older than: in each group, select "Don't check" (default), "Created date" or "Modified date", and enter a date or a Variable. An item matches Newer than when it is newer than the date, and Older than when it is older
- The "AND" (default) or "OR" list between the groups: whether an item must match both groups or one of them
Both "Created date" and "Modified date" compare the date with the modified date of the item. With "OR", set at least one of the groups; when neither is set, no item matches.
Delete file(s): Size tab
- Check if file is smaller than x size and Check if file is larger than x size: match items smaller or larger than the size, in "byte(s)", "kilobyte(s)", "megabyte(s)", "gigabyte(s)" or "terabyte(s)"
- The "AND" (default) or "OR" list between the groups: whether an item must match both checks or one of them
With "OR", every item matches unless Check if file is smaller than x size is checked.
Delete file(s): Result tab
- Sort (in the Sort result group): sort the matching items by "Full path", "File name", "Modified date", "Created date" or "File size", "Ascending" or "Descending". Sorting by "Full path" makes the Task fail with an error; use another column
- Limit (in the Limit result group): use only the first number of matching items, after sorting. The value can be a Variable
Delete file(s): Test tab
Click Show filtered files to ask the Server for the items that match the current settings. The number of items found and the time it took are shown.
Output and errors
The output of the Task is the path of each deleted item, one per line. When no item matches, the Task deletes nothing and succeeds; unlike List file(s), it does not report an error.
With "Folders" or "All" in Filter, each matching folder is deleted with all its content. Files are deleted even when another user has them open. Use the Test tab to check the matching items before the Task runs.
When an item cannot be deleted, the error is written to standard error, the Task goes on with the next item, and the Task reports success.