how to delete files in macOS automator
I am developing an automation (automator 2.10) in macOS Catalina (10.15.7) to input a downloaded file (.csv) into a Numbers (11.1) spreadsheet, select and copy all the transactions, and then paste them into a new spreadsheet using a template. There are several operations that need doing after this e.g. formatting the date column into date format and sorting into ascending sequence so that it's easier to check against the paper statement.
One of the things I have found vital to do is to always bring the spreadsheet window into focus first when starting to "record" keyboard and mouse selections. When doing this on the csv spreadsheet it actually refers to it with the dowloaded file name. The filename is unique as it includes the date and time downloaded so (I'm assuming) the automation won't work on next month's file.
So, I thought, once the downloaded file has been selected in the automation (it prompts the user to select it from the Downloads folder), copy it to a working folder and then rename it to the same name every time. But the rename won't work if it already has a file of the same name in the folder, so it needs deleting first.
I am just trying to delete a specific file from a specific folder but I can't work out what actions I need to do this. I've practically sorted out everything else.
Can anyone help please?
iMac 27″, macOS 10.15