A very simple way to delete files (not folders) across multiple levels of folders, for files older than a specific date in SharePoint online is to use a Power Automate flow.
Here is what is required for the flow:
Get files (properties only)
- Include Nested Items: Yes (This is required if you need to delete files across multiple levels of subfolders)
- Filter Query: Set to your respective date value. (Example below is where created file date is earlier or equals to 31st December 2022)
Condition **in **Apply to each.
- Check if IsFolder **is equals to **false. This is because Get files will also returns folder names.
If yes, Delete file
- File Identifier: Identifier (from the Get files (properties only) action)
If no, do nothing
Top comments (0)