Delete file using FileManager?

Would it be possible to add a delete(path) function to ’FileManager` so that we can delete files from a script?

Perhaps through a Workflow delete action ?

( The intersection of ‘script’ and ‘delete’ can be quite a dangerous place )

What is the use case you’re thinking of? Is it for active file management or for removing temporary or cached data? There may be safer alternatives.

Since I don’t know how to store a token in Credential I’m currently storing it in a file using FileManager. The service that requires this token might invalidate it. I would like to delete the file when that happens (instead I currently write an empty string to that file).

I’d just use a dot file with your existing approach. Out of sight out of mind. Can’t be more than a few hundred bytes.

1 Like

Did not think of starting the name with a dot. Good suggestion! Thanks.

1 Like

I’d be interested in delete support as well. I have an action to save out files with a specific set of tags. Periodically, I like to update the saved files to match whats in drafts. It would be nice to be able to delete the folder first, before saving the new files, to handle drafts that have been removed and I’d like to delete from the Drafts folder as well.

I handle this manually now, periodically deleting the folder from the Files app, and then saving again. It would be nice to have support for automating this, edven knowing that deleting from scripts can be a dangerous combination.

I would love the ability to delete folders with FileManager. I’m setting up my blogging workflow in Drafts and I auto-create Draft specific folders using the UUID under Libarary/Previews/images to make it easier for me to later delete them without deleting images for Drafts I’m currently working on. I’d love to have a one-button purge action that just deletes the whole folder matching the current Draft UUID.