This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
on 03-15-201604:58 PM - edited on 07-27-202111:43 PM by APIUserOpsDM
One of the many great things about Alteryx is how it can assist the user in organizing their data not only within the tool, but outside of the tool as well. In this series we will show you how to rename, move, and delete input files that you use in your Alteryx Workflows. You will create batch files with Alteryx that you will later be able to use in a workflow that runs the file. This will give you the ability to stay organized as to what you have run through the workflow.
The first one we will go over is Renaming Spreadsheets.
Creating the Batch file workflows:
Tools needed in order of use: (1)Directory Input, (2)Select, (3)Formula, (4)Summarize, (5)Output Tools.
Directory Tool (1) –
Browse to the file or files you are looking to change
Select Tool (2) –
Fields you will need are Fullpath, Directory, and File Name
Formula Tool (3) – Output Fields Created: New File Name, Command, and Batch File.
Create a new field, New File Name (String) – Create the new name either by adding a name with quotes around it, from a field, or in like the example below, adding the runtime date of the file to the file name.
Sample Expression of adding the run Date from Directory Tool as the renamed file:
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.
Sample Output - C:\Users\JDoe\Documents\Sample Data\Command Line Test\rename_files.bat
Summarize Tool (4)–
Select the Command field and the action will be to concatenate using a separator as \n.
Select the Batch file and the action will be First.
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) –
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.
In the Delimiters Row in the Options section add \0 as the delimiter.
Select Take/Table Name From Field and choose Change Entire File Path.
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:
Select Add > Run Command> Run Event When> After Run>