Inspire EMEA 2022 On-Demand is live! Watch now, and be sure to save the date for Inspire 2023 in Las Vegas next May.

Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

Batch Files in Alteryx Part 3: Deleting Files

Alteryx Community Team
Alteryx Community Team

This is the third article in the series of renaming, moving, and deleting files using a batch file. This workflow will create a .bat file which you can use in other workflows that use the files you specify in this workflow to delete files.


WARNING: Please be careful using this command as it will do what it says it will do. Test thoroughly before adding to production.


Deleting Files


Creating the Batch file workflows:

Tools needed: (1)Directory Input, (2)Select, (3)Formula, (4)Summarize, (5)Output Tools.


Directory Tool (1) –

  1. Browse to the file or files you are looking to change


Select Tool (2) –

  1. Fields you will need are Fullpath, Directory, and File Name


Formula Tool (3) – Output Fields Created: Command and Batch File.

  1. Create a new field, Command (String)This is the field you want to build your command.
    • Expression:
      'DEL '+ '"'+[FullPath]+ '"'+ ' ' + + '"'+[FileName]+ '"'
    • Sample Output - DEL "C:\Users\dmenke\Documents\Sample Data\Command Line Test\$200.xlsx" "$200.xlsx"
  2. Create a new field, Batch File (String) – You will take the Directory field from the Directory Input and add a name of what you want the Batch File to be.
    • Expression:
    • Sample Output - C:\Users\JDoe\Documents\Sample Data\Command Line Test\rename_files.bat

Summarize Tool

  1. Select the Command field and the action will be to concatenate using a separator as \n.
  2. Select the Batch file and the action will be First.
  3. You can rename the Output fields if you choose as it will change the fields to Concat_Command and First Batch File.



Output Tool (5) –

  1. Browse to save file as any name you want (you will be replacing this name). You will want to use the Save as type: (.csv) and add .bat to end of the name. We want to transform that txt file to a bat file.
  2. In the Delimiters Row in the Options section add \0 as the delimiter.
  3. Select Take/Table Name From Field and choose Change Entire File Path.
  4. Select the First_Batch file (or name you called the field) in the Field Containing File Name or Part of File Name and unselect Keep Field in Output.



Adding Batch File to Your Workflow:

The last step is to add this batch file to the Events tab in a Workflow that you want to move the file or files you have chosen in the .bat file in the Configuration window.

  1. Select Add > Run Command> Run Event When> After Run>
  2. Command: Browse to the bat file and click Ok.


See attached Sample Workflow.


No ratings
5 - Atom

Great post DanM!


Just to add - you can also set the Run Command Tool to output the batch script to a "temp" directory so that it can stay within the Alteryx workflow and can be "lifted and shifted" as required.

7 - Meteor
Hi, is this working in server workflow schedule to delete a share folder file?
5 - Atom

Hi DanM,


I'm new to the community and would like to download your workflow on this, but cannot open the attachment?

8 - Asteroid

Thanks for the walkthrough! Worked for me first try.🎸 Rock N Roll!

14 - Magnetar

If anyone is interested, i built a macro with the python component to do this same task. It is an alternative :)


Delete Files - Alteryx Community

5 - Atom

Could you please provide a script to delete files from SFTP folder as well? I tried above to delete files from SFTP but it did not work.