Moving or Copying files Using Alteryx

There are a number of ways to move or copy a file using Alteryx, I’m going to showcase two approaches and talk about the benefits and drawbacks.

Run Command Tool

The first approach uses the Run Command tool which is used to run external programs within Alteryx. In this example it’s uses a Batch File to move an Excel file.

Alteryx: Run Command

For this approach to work you need the full path of the file you want to move and the destination of the output folder.

Text Input: Filepaths

Next within a formula tool you want to generate your command to be executed which in this case is fairly simple. The code is simply a move command with the filepaths (‘move “‘+[FullPath]+'” “‘+[DestinationDirectory]+'”‘)

Formula: Move File

In the configuration of the Run Command Tool, we want to output our command to a Batch File so within Alteryx when we hit run it executes.

Run Command: Move File

The conclusion of this setup is that a file would be moved from one folder to another. Which is useful if you want to archive files after processing them. However, there is one drawback with using “move” command in this setup. Which is if the file is open this approach would fail and produce an error in Alteryx.

Run Command Tool – Copy

A way to deal with errors if the file is open is to change the command to “copy” this will copy the file even if it’s open and place it into our destination folder.

Run Command: Copy Formula

As we are copying the file it means a version of the file will still be left in the original folder where we initially copied it from. However, this could be dealt with another Run Command to delete files. Alteryx has the option in the workflow configuration to run events before a workflow or after. Therefore, you could easily have a run command file to delete files in a directory before or after running.

Alteryx: Events

Benefits – Drawbacks Run Command

The run command is a powerful tool and opens up a number of possibilities and as shown can be configured to deal with different scenarios. However, because it’s such a powerful tool and can be used to run external command programs it’s typically seen as a potential IT security risk. Therefore, any production processes that would want to use this approach, would normally need to engage with their IT security team. This approach does have a learning curve as users may feel daunted with coding a run command.

Blob Approach

The second approach you can use to copy files to a new location is to use Blob tools in Alteryx. Essentially you feed in the input path of the file to be ingested into Alteryx and it’s converted to a Blob data type with a Blob Input tool. Then you feed the output file path with the blob of your file from the Blob Input tool in the Blob Output tool. This mimics the Run command Tool approach of copying a file.

Blob Tools: Copy Approach

For the Blob Approach you will need the full path of the Input and Output location with the file and correct file extension.

Text Input: Filepaths

The Blob Input Tool configuration is relatively simple you will need a File Name, change Modify File Name By to “Replacing Entire Path with Field” and in the drop down select your field.

Blob Input: Configuration

The Blob Output tool follows a similar configuration however it requires a Blob field to work. However, since we are using the Blob Input tool to convert our file to a Blob we have got this covered.

Blob Ouput: Configuration

Benefits – Drawbacks Blob

The Blob approach is simpler to setup and learn when compared to the Run Command approach. However, while the Blob approach mimics the copying approach of the Run Command Tool. It would error unlike the Run Command Tool approach if the file were open.  It should be stated that an IT security team would probably be less concerned with the Blob approach. The reason being, that copying a file is the only thing it can do in this scenario and it’s not utilising, an external command program to accomplish this task. Therefore, would be less of a risk of this process being used in malice intent.

In summary these are just two approaches to moving/copying files with Alteryx. As you can see there are benefits and drawbacks to consider when adopting these approaches.

Hope you find this blog helpful and can see that you can use Alteryx for a variety of scenarios. Please leave a comment below or reach out to me on Twitter @JosephSerpis or on the Alteryx Community and Linkedin.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s