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
- Open Power Automate.
- Click Create.
- Select Scheduled Cloud Flow.
- 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
- Delete files by file name.
- Delete files by extension.
- Delete files based on metadata.
- Delete temporary uploads.
- Delete expired documents.
- Archive before deletion.
Benefits
- Reduces storage consumption
- Automates document cleanup
- Improves governance
- Supports compliance policies
- Eliminates manual maintenance
Key Takeaways
- Power Automate can delete SharePoint files automatically.
- Scheduled flows are commonly used for cleanup processes.
- Files can be deleted based on age, metadata, or business rules.
- Always validate conditions before deletion.
- Consider archiving files before permanent removal.