How can I delete files older than N months?

To delete a filtered range of files, you must write a script to list the files, filter them, and batch-delete them.

Instructions

  1. Fetch every file for a folder using the ListFolder operation.
    1. You may need to call this operation multiple times for large folders, as results may be paginated.
  2. Filter the files you want to delete using a script.
    1. For example: you can inspect the lastModified field for each file to determine its age, and then decide whether to delete the file or keep it based on this value.
  3. Call the DeleteFileBatch operation in batches of 1000 for the files from step (2).
    1. This is an asynchronous job: you can check each request's status using the GetJob operation.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us