0

Cannot seem to delete files from the SFTP in Automation Studio. It returns success but doesn't delete.

Step 0) Transfer file hello_world_2021-05-27T17-06-19Z.csv to sftp import folder.

Create Automation with the following:

Step 1) Create File Drop for files which start with hello_world_

Step 2) Import into DE

Step 3) Delete file from Import folder with Data Extract Filenaming Pattern: %%BASEFILENAME_FROM_TRIGGER%%.csv Extract Type: Delete File from ET FTP or Safehouse

FTP Folder: Import Input Filename: %%BASEFILENAME_FROM_TRIGGER%%.csv (to match naming pattern above)

Alternate Test:

Open SFTP via terminal.

  1. cd Import
  2. rm hello_world_2021-05-27T17-06-19Z.csv

Result:

Removing /import/hello_world_2021-05-27T17-06-19Z.csv
Couldn't delete file: No such file or directory

--

Any insight into why I can't delete files from the SFTP would be appreciated, thank you.

Edit: If i write a manual filename in and execute the activity once, it will delete. It's when i try to use substitute strings that it doesn't work. Can anyone else confirm that they have this working? Thanks.

1 Answer 1

-1

Unfortunately, you cannot use the usual Substitution string in Data Extract activity. Remember that those Substitution strings are applicable only in Import and File Transfer activities.

To dynamically select a file in Data Extract, you can add some Date and Time Substitution Strings like:

  • %%Year%%: four-digit year
  • %%Month%%: two-digit month
  • %%Day%%: two-digit day
  • %%Hour%%: two-digit hour
  • %%Minute%%: two-digit minute
  • %%Second%%: two-digit second

For example - hello_world_%%Year%%-%%Month%%-%%Day%%.csv - probably it is not good to add lesser time parts since Data Extract will always need to match the current time and date to the numbers in the file name.

5
  • That idea is only for move/copy and didn't specify the deletion of files. Assuming that it can't be used. Every file requires a unique name due to SFMC limitation in different regards, so how do I delete the file that I uploaded if i can't access the substitution strings? Is there any way to delete files older than 24 hours and matching a certain pattern or something? Thank you.
    – user80446
    Jul 17, 2021 at 16:20
  • No, there is no way to add up some calculation and you are limited to one option to adjust the file naming in order to successfully manage importing and deleting at the same time.
    – Niko
    Jul 17, 2021 at 16:25
  • To summarize, the only option is to have a static filename with no dynamic parts in order to delete it from SFTP via Automation Studio. Is my understanding correct?
    – user80446
    Jul 17, 2021 at 16:44
  • Not fully correct, as I mentioned in the answer, you can use date and time substitution strings, which would let you have some level of dynamic naming pattern.
    – Niko
    Jul 17, 2021 at 17:37
  • Appreciate it, thanks. It's unfortunate.
    – user80446
    Jul 18, 2021 at 0:45

You must log in to answer this question.