Alteryx Designer Desktop Discussions

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

Dynamic Create File Directory

patrick_mcauliffe
14 - Magnetar
14 - Magnetar

Is there a tool to dynamically create a new file directory on the hard drive (or network drive); whereby the file directory name would be a field in the incoming data, and the file would be a report coming from the Render tool?

 

I’ve used the command prompt tool to create directories (MKDIR) but never been able to use dynamic naming.

17 REPLIES 17
PamW
Alteryx Alumni (Retired)

Yep that \0 for no delimiters is important!

pamW
nextelspe
7 - Meteor

I fought with this for hours, come to find out my company's IT group policy doesn't allow .bat files to run!  Is there an other way of doing this without using a .bat file?  I'm trying to write to a bunch of folders that do not yet exist, hence my need to automate their creation.

patrick_digan
17 - Castor
17 - Castor

@nextelspe I'm attaching a simple example of using the run command tool inside a batch macro. I just used the md command and passed the folder that you want created. This is very bare bones, but it may help you. If you can't run .bat files, I am unsure then if you will be able to use the run command tool and call cmd.exe like my example.

blyons
11 - Bolide

@patrick_digan, thank you for that simple and brilliant solution! I had a similar problem, and this solution is perfect.

 

I did have one problem in that it throws an error if the folder already exists. So, to fix that, I changed the command line arguments to:

/c IF NOT EXIST "%Question.ControlParam.File%" md "%Question.ControlParam.File%"

 

There are a couple of things I'd like to understand about how and why this works. Can you explain:

  1. The Write Source %temp%testing.yxdb. What does that do?
  2. "%Question.ControlParam.File%" - clearly this passes the filename parameter. But I don't understand how or why. What is the syntax of this? Is there a document somewhere that details it?

Thanks again!

patrick_digan
17 - Castor
17 - Castor

@blyons I'm glad I could help,and it's great that you've made it even better.

 


@blyons wrote:

 

 

There are a couple of things I'd like to understand about how and why this works. Can you explain:

  1. The Write Source %temp%testing.yxdb. What does that do?

The Run command tool has to either write data out or read data in. This is very powerful at times. When situations come up where I really don't need it to read/write, I just have it write dummy data to a temp file. The %temp% is the alteryx temp folder path, and I just write one dummy line to the testing.yxdb line. After the run command tool writes out that data, then it runs the command. 

 


@blyons wrote:

 

 

There are a couple of things I'd like to understand about how and why this works. Can you explain:

  1. "%Question.ControlParam.File%" - clearly this passes the filename parameter. But I don't understand how or why. What is the syntax of this? Is there a document somewhere that details it?

Thanks again!


 The syntax is %<<type>>.<<name>>%. If you click anywhere on the canvas, then go to the workflow tab of the workflow configuration panel, you can see all the constants that you can call this way:

9lllav

 

So %Engine.TempFilePath% (equivalent to %temp% when used in Alteryx) and %User.Test% would work along with %Question.ControlParam.File%. These are very versatile and can be used in more places than normal fields. They also eliminate the need for action tools to pass variables. @AdamR_AYX passed that tip to me awhile back on a community post I had. It's an undocumented feature that I have found a lot of use for.

 

 

cbz
8 - Asteroid

Hi

 

I have come across with the same problem, I have downloaded your solution workflow.

 

It works fine if it just L:\mytest but when I trying to extend the path longer by wanting to create more sub documents. It failed.

 

The Error message says "the external program "run_mkdir.bat" returned an error code:1"

 

What is  "run_mkdir.bat" actually do?

 and the front code: Folder.bat ( what is it mean?)

 

I am wondering why is this? any solution?

 

I have also attached the changes I made in the workflow.

 

Thanks

 

Chunbin

blyons
11 - Bolide

If you use @patrick_digan's version "Create Folders.yxzp," neither of those batch files are used, and that error does not appear, even with multiple levels of subfolders. Simple. Elegant.

Kenny9402
5 - Atom

Hello,

 

So I have been trying to use the suggested method for my analytic app to create subfolders before actually outputting anything to them. The batch files runs fine, the subfolders are dynamically created without any problem.

However, since the output tool verifies the output path at the very beginning,the app comes back with the "Cannot access C\:whateverfolder". So at the moment, I need to run the app twice, once to create the subfolders and the second time to actually run the workflow. I have tried both the "Block Until Done" and "Parallel Block Until Done", but it's still the same. Any suggestions in how to fix this?

 

Regards,

Kenny

Labels