How to delete all files in a SharePoint folder using Power Automate?

    Do you want to delete all files from a SharePoint or OneDrive folder? In this Power Automate tutorial, we will see how to delete all the files from a SharePoint folder using Power Automate.

    We will also cover how to delete files from the OneDrive folder using Power Automate and how to delete files older than 30 days from the SharePoint folder using Power Automate.

    Sometimes, when you’re using a tool like SharePoint or OneDrive for a task, you might create a file for a specific purpose while the task is happening.

    However, once the task is done, you don’t need that file anymore. It’s a good idea to remove or delete it so you don’t end up with unnecessary files taking up space in your storage.

    To automate this process, we can use the Power Automate Delete file action available for SharePoint and OneDrive.

    Power Automate delete all files in the SharePoint folder

    Here, we will see how to delete all files in the SharePoint folder in Power Automate.

    For example, I have a SharePoint document library, and inside the library, I have a SharePoint folder called ‘Invoices [Not required]’, and we need to delete all files from this SharePoint folder. For this, follow the below steps.

     delete files in folder power automate

    1. In Power Automate Cloud, create an Instant cloud flow that will trigger Manually.

    power automate delete file

    2. Next, we will get files from the folder; for this, click on the +New step -> select ‘Get files in Folder (Properties only)’action. Then provide the information below

    • Site address: Provide the SharePoint site address
    • Library name: Provide the Library name
    • Limited entries to folder: Select the folder path from dynamic content
    • Include Nested Items: Select Yes
    power automate delete all files in sharepoint folder

    3. Now, we will delete all files available in the folder; for this, click on the +new step -> select Delete file action. Then provide the below information:

    • Site address: Provide the SharePoint site address
    • File identifier: Select the Identifier from dynamic content. This will automatically add Apply to each action to the flow.
    power automate delete files in folder

    4. Now run the flow manually, and you can see all the files deleted from the SharePoint folder in Power Automate.

    power automate delete files in sharepoint folder

    This is how to delete all files in the SharePoint folder using Power Automate.

    Delete all files from OneDrive folder using Power Automate

    Here, we will see how to delete all files in the Onefrive folder using Power Automate.

    For example, I have a OneDrive folder, ‘Invoices [Not needed]’, and I need to delete all files available in that folder using Power Automate. I have followed the below steps.

    power automate delete all files in onedrive folder

    1. In Power Automate Cloud, create an Instant cloud flow, which will trigger manually.

    Power Automate delete files onedrive folder

    2. Next, we will get all files from the Onedrive folder. For this, click on +New step -> select List files in folder action. Provide the below information:

    • Folder: Select the path of the folder.
    delete files in oneDrive power automate

    3. Now, we will delete the file from the Onedrive folder; for this, click on the +New step -> select Delete file action. Then provide the below information:

    power automate delete all files in onedrive

    4. Now save and run the flow manually, and you can see all files are deleted from the OneDrive folder.

    power automate delete files in folder onedrive

    This is how to delete all files from the OneDrive folder using Power Automate.

    Power Automate delete files older than

    Here, we will see how to delete files older than 30 days in Power Automate.

    For example, I have a Sharepoint folder called ‘Excel Sheets’, i need to delete files that are older than 30 days using Power Automate; for this follow the below steps.

    power automate delete files older than

    1. In Power Automate Cloud, create an Instant cloud flow and that will trigger Manually.

    power automate delete file

    2. Next, we will get files from the folder that are older than 30 days; for this, click on the +New step -> select ”action. Then provide the information below

    • Site address: Provide the SharePoint site address
    • Library name: Provide the Library name
    • Limited entries to folder: Select the folder path from dynamic content
    • Include Nested Items: Select Yes
    • Filter query: Provide the below expression:
    Created lt'@{addDays(utcnow(),-30,'yyyy-MM-dd')}
    power automate delete files older than 30 days

    3. Now, we will delete all files in the folder older than 30 days; for this, click on the +new step -> select Delete file action. Then provide the below information:

    • Site address: Provide the SharePoint site address.
    • File identifier: Select the Identifier from dynamic content. This will automatically add Apply to each action to the flow.
    power automate delete files in folder

    4. Now run the flow manually, and you can see all the files deleted from the SharePoint folder in Power Automate.

    power automate delete files older than X days

    This is how to delete all files in the SharePoint folder that are older than 30 days using Power Automate.

    Conclusion

    In this Power Automate tutorial, we saw how to delete all files in the SharePoint folder using Power Automate. Also, we cover the below topics

    • Power Automate delete all files in OneDrive folder
    • Power Automate delete files older than 30 days

    You may also like:

    comment_count comments
    Oldest
    Newest
    Oldest

    Comment as a guest:

    >