Move or Copy files in Alteryx


This post describes how to move a file in Alteryx. To move or copy files in Alteryx use the Run Command tool.

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

The method to move or copy a file in Alteryx is almost identical. Using the example below, simply replace the MOVE command with COPY or XCOPY.

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. Start the move or copy with a Text Input tool.

Enter the above fields into a Text Input tool.

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

alteryx text input tool configured with a file path and directory

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

2. Write the Move or Copy command in a Formula tool

Add a formula tool. Build the move / copy command line text in the Formula tool.

In this example I name the field ‘cmd’.

I strongly recommend first writing the command line text in Notepad then testing in the command line interface.

This is to ensure the command works as expected.

For those less familiar with the command line interface, type “cmd” in 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’.

set up an alteryx formula tool to write the move command
Write the Move command as an Expression

3. Next step is to add a Select tool

Select only the new ‘cmd’ field. Only pass one field into the Run Command tool. Here we use the ‘cmd’ field.

4. To finish the move or copy add a Run Command tool

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; called MoveFiles in this example. Therefore enter %temp%\MoveFiles.bat in the Command section.

configure the Alteryx Run Command tool to create a bat file
Configure the Run Command

When setting up the Run Command you may notice some errors. This is likely to be because the file in the Command section doesn’t yet exist.

Simply running the workflow should remove the errors.

The final workflow is as follows:

Alteryx workflow with 4 tools to move or copy files
The final Alteryx workflow to move or copy files

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

7 thoughts on “Move or Copy files in Alteryx”

  1. I am beginner in AlterYX. Finally, I got my answer after many hours of surfing the web by reading your article. hope to see more posts on this technology.

    • Totally agree. So many “answers” but they all omit critical steps or information that may not be obvious to newer users. This solution, while not elegant, certainly does the job. Thanks for this!

  2. If you have a number of files you are looking to copy/move you should use the .csv file type instead of the .flat

  3. Could this copy only certain sheets? I have a file with 5 sheets that I’d like to copy 3 to a new file, preserving formats.

  4. This is a really useful tutorial for anyone who needs to move or copy files within Alteryx. The step-by-step instructions are easy to follow and the accompanying screenshots make it even easier to understand. The author does a great job of explaining the different tools available in Alteryx for file management and how to use them effectively. The tips and tricks provided throughout the article are also very helpful. Overall, this is a great resource for anyone who wants to streamline their workflow in Alteryx and save time on file management tasks.


Leave a Comment