This post describes how to move a file in Alteryx. To move or copy files in Alteryx use the Run Command tool. To copy a file in Alteryx is almost identical, simply replace the MOVE command with COPY or XCOPY. The change should be made in step 2, below.

As the name of the tool suggests the tool runs command line scripts. Therefore anything that runs on the command line can also run in Alteryx.

In previous posts I’ve written about other use cases for the Run Command tool. Examples include how to publish a tableau extract to tableau server and how to unzip a file in Alteryx.

How to move or copy files in Alteryx

To move or copy files in Alteryx requires two pieces of information:

  1. File path of file to move
  2. Destination directory

Set up the Alteryx workflow as follows:

1. Enter the above fields in a Text Input tool.

This step creates the “FullPath” (#1 above) and “DestinationDirectory” (#2 above) fields.

Alteryx Move Copy Text Input

Note: The backslash at the end of the DestinationDirectory is very important. Without the back slash a new file will be named Engine and stored in the folder D:\Alteryx. We want the file stored in the Engine folder.

2. Next add a Formula tool.

This is to create the Move command line. Here I call the field ‘cmd’.

I strongly recommend the command line text should be first written in Notepad and then tested in the command line. This is to ensure the command works as expected. For those less familiar with the command line, typing “cmd” of your machine search box should open the command prompt box. This is where you run the command line scripts.

To COPY a file instead of MOVE edit this command expression. To copy a file the expression should begin with ‘copy’ rather than ‘move’.

Alteryx Move Copy FormulaTool

3. Next step is to add a Select tool.

Select only the new ‘cmd’ field. Only pass one field load into the Run Command tool. In this case use the ‘cmd’ field.

4. Finally add a Run Command tool to the workflow.

The Run Command tool takes the command text (written in the field ‘cmd’) and converts it to a bat file. The tool then runs this bat file.

a. The Write Source Output creates the .bat file. Set this as a .flat file or .csv – any file type that’s a flat text input. (If using csv ensure there’s no delimiter set; the First Row does not Contain Field Names; and Quote Output Fields Never.) In this example the bat file is written to the Alteryx temp directory, %temp%. The file name is MoveFiles.bat.

b. In the Run External Program Command section we run the .bat file; MoveFiles in this example. Therefore enter %temp%\MoveFiles.bat in the Command section.

Alteryx Move Copy Run Command

When setting up the Run Command you may be presented with a few errors. This is likely to be because the file looked for in the Command section doesn’t yet exist. Simply running the workflow should remove the errors.

The final workflow is as follows:

Alteryx Move Copy Workflow

Credit for the post also must go to s_pichaipillai on the Alteryx forum.