We have extended our Early Bird Tickets for Inspire 2023! Discounted pricing goes until February 24th. Save your spot!

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer and Intelligence Suite.
SOLVED

Copying multiple text files from one folder to different locations based on a filter

nchikara
6 - Meteoroid

Hi All,

I am currently working on a project where a workflow dump multiple text(.txt) files in a common folder/file location.

For example,

Boston.txt

Dallas.txt

Atlanta.txt

 

Now, I need to copy/move these files from this common file location to city based folders. 

For example,

Boston.txt file should go Boston folder

Dallas.txt  file should go to Dallas folder respectively.

Since there are hundreds of files moving each of them manually takes more time. Is there any way where I can create a workflow so that they are automatically picked and moved to desired location.

 

All the help would be appreciated!

 

Thanks,
Nancy

 

 

7 REPLIES 7
pcatterson
11 - Bolide

Yes, but the folders must already exist.  Alteryx will not create the desired subfolders for your destinations.

RodL
Alteryx Alumni (Retired)

Or you could go down the road of creating a batch file within Alteryx (relatively easy to do with the Directory and Formula tools) that you could run after its creation (either manually or as an Event you add to the workflow).

A fairly detailed article that was part of a series related to this can be found here.

nchikara
6 - Meteoroid

Hi Pcatterson,

 

For my project there are two steps,

 

Step1: 

Using your solution for dumping all files in a common log folder like Boston1.txt,Boston2.txt,Boston3.txt, Dallas1.txt,Dallas2.txt,Dallas3.txt, etc.

 

Step 2:

Once they are dumped there we need to copy them into production folders in such a way that all Boston file are copied to Boston folder,all Dallas files are copied to Dallas folder, etc. without again reading them.

I figuered step1 but I am still struggling to figure out second step. I would appreciate all your help! 

 

Thanks,

Nancy

 



 

RodL
Alteryx Alumni (Retired)

@nchikara

I had a customer that did something very similar and used the "build out the batch file" process to move the files once created.

I've attached an example. This just runs within the same workflow that creates the files and then you call it as an Event.

nchikara
6 - Meteoroid

@RodL

 

You got it right, it is what I am looking for. I tried your workflow and have a question for you,


Could you please explain how does exactly Formula tool,Transpose tool and Trim tool are creating .bat files? 

My apologies for asking so many questions but I am just a beginner and it takes me little time to understand things.

Appreciate all your help!

 

Thanks,
Nancy

 

 

RodL
Alteryx Alumni (Retired)

So the Formula tool basically creates line-by-line what goes in the .bat file. Because of how you can build expressions in Alteryx with dynamic data from your data flow, you can make the creation of the .bat file dynamic as well.

 

Since a Formula tool basically adds fields "horizontally", you then need to get the values you are creating for the .bat file into a line-by-line basis (i.e., "vertically"). That's where the Transpose tool comes into play. It will take the fields and stack them as rows.

 

The Trim tool is merely to eliminate white space, and depending on how you configure the lines in the Formula tool, you may not need it.

 

I have attached a workflow that allows for doing this with multiple files. So assuming you have the Boston, Chicago, and Dallas .txt files created in a single directory, this will create a batch file that checks for folders for those three entities and then copy/delete the files from the original location.

nchikara
6 - Meteoroid

@RodL,

Thank you so much for explaining the solution.This is exactly what I am looking for.

Appreciate all your help!

 

Thanks,
Nancy Chikara

Labels