Delete File from SharePoint Using Power Automate

Delete File from SharePoint Using Power Automate

Managing files in SharePoint document libraries is an important part of maintaining storage efficiency and ensuring compliance with organizational policies. Over time, document libraries can accumulate outdated, temporary, or unnecessary files.

Power Automate allows organizations to automatically delete files from SharePoint based on specific business rules, schedules, or file conditions.

Business Scenario

Suppose your organization stores temporary reports in a SharePoint document library. Files older than 30 days should be automatically removed to reduce storage consumption and improve document management.

Step 1: Create Scheduled Flow

  1. Open Power Automate.
  2. Click Create.
  3. Select Scheduled Cloud Flow.
  4. Configure the recurrence schedule.
Recurrence

Frequency:
Daily

Interval:
1

Step 2: Get Files from SharePoint

Get Files (Properties Only)

Site Address:
SharePoint Site

Library Name:
Documents

Retrieve files from the target document library.

Step 3: Filter Old Files

@less(
item()?['Created'],
addDays(
utcNow(),
-30
)
)

Identify files older than 30 days.

Step 4: Delete File

Delete File

File Identifier:
Identifier

Use the Identifier value returned from the SharePoint action.

Flow Design

Recurrence
      ↓
Get Files
      ↓
Apply to Each
      ↓
Condition
      ↓
Delete File

Alternative Scenarios

Important: Always test the flow in a non-production environment before enabling automatic deletion. Consider moving files to an archive folder before permanent removal.

Benefits

Key Takeaways