Delete File/Folder

🔹 Definition

The “Delete File/Folder” action allows you to permanently remove a specific file or folder from your OneDrive storage. This action helps automate file cleanup, manage outdated documents, or maintain organized directories by deleting unnecessary items as part of a workflow.

It supports selecting the item either by ID or path, and is compatible with dynamic flows—meaning you can delete different files or folders based on previous steps using tokens. Whether you’re managing document lifecycle, archiving, or reacting to certain events (e.g., task completion), this action ensures OneDrive stays clutter-free and up-to-date.



Example Use Cases


1. Remove Temporary Files After Processing

Automatically delete temporary or intermediate files after they’ve been processed (e.g., converted, renamed, or moved) to keep storage clean.


2. Clear Outdated Reports or Logs

Set up scheduled flows to delete old reports, log files, or exported data (e.g., older than 30 days) from a specific OneDrive folder.


3. Delete Files After Approval or Rejection

In workflows where documents are approved or rejected (e.g., HR forms, invoices), delete unnecessary versions or drafts to avoid duplication.


4. Manage Folder Cleanup After Task Completion

Automatically delete an entire folder associated with a completed project or ticket (e.g., in support or project management scenarios).


5. Enforce Compliance or Retention Policies

Implement data retention policies by removing specific files or folders after a defined time period for security, legal, or compliance reasons.



🔹 Inputs

These are the fields required to configure the Delete File/Folder action. This action allows you to permanently delete a specific file or folder from your OneDrive.


  1. Connection This refers to your authenticated OneDrive connection. It enables Zenphi to securely access your OneDrive environment and perform the file copy action on your behalf. You must set this up before configuring other fields.

  1. Selecting File or Folder The item (file or folder) you want to delete from your OneDrive. You can provide this in two different ways depending on your setup:
  • Interactive Selection (Recommended): Click the OneDrive icon in this field to launch a popup. From there, you can visually browse and select the file or folder directly from your OneDrive.

  • Dynamic or Manual Input:

    • ID Method (when ‘Select By Path’ is disabled): Provide the unique identifier of the item (e.g., 1EED600A8F0FD9A1!s75181466e59d4bacb1ec55930b932ed1). This ID is typically retrieved from a previous OneDrive-related step in your flow.

    • Path Method (when ‘Select By Path’ is enabled): Provide the full OneDrive path to the item (e.g., /drive/root:/Documents/Reports/OldReport.pdf). This is especially helpful when referencing known folders or structured directories.

💡

Tip: If you are working with dynamic data from earlier in your automation flow, use the Token Picker to pass the item ID or path from previous steps.



Example:

Imagine you have a workflow that automatically cleans up outdated files from your OneDrive to keep your storage organized.

Scenario: You want to delete a report file named "Monthly_Sales_Report_2023-01.pdf" from the folder "Reports/Old" after the report is no longer needed.

How to set it up:

  1. Add the Delete File/Folder action to your flow.
  2. For Selecting File or Folder, click the OneDrive icon to open your OneDrive file picker. Navigate to the Reports/Old folder and select the file "Monthly_Sales_Report_2023-01.pdf". Alternatively, if your flow already retrieved the file ID or path earlier, use the token picker to dynamically pass that value here.
  3. Save and run your flow. When triggered, this action will permanently delete the specified file from your OneDrive.

This way, your automation flow can maintain a tidy OneDrive by removing files or folders that are no longer necessary without manual intervention.