Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

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
kane_glendenning
10 - Fireball
Hi Patrick,

I use the Run Command tool for this. In a formula tool before the Run Command, I make a field the will be something like this: "MKDIR " + [DirectoryField], I then remove all other fields and feed that into the Run Command tool to make a batch file (Write Source/Output) and run that batch file (Run External Program). You can use Block Until Done to make sure that your folders are created before saving to that directory. 

Kane
dawid_nawrot
9 - Comet

Can someone post a working example of this configuration?

 

I'm trying to use Run Command to create folder but I'm getting "Either an Output connection or Input connection is required" 

 

When I specify ma *.bat file in Output it says the format is not known

PamW
Alteryx Alumni (Retired)

Attached is an example that allows you to enter different folders and requires a full path

 

  1. Text input that has the path to the folder in a field called "DIR", in my case I entered the field value as D:\mytest.
  2. Formula tool to write a command for a bat, this is allowing me to run the second batch with different parameters (there are a lot of ways I could approach this).
  3. Run tool outputs the batch file to run and then configure to run it, attached to the Run tool is another batch that actually does the mkdir, the input is a log that shows whether the directory was created or if the directory already exists.

Let me know if this works for you.

pamW
sayakm
6 - Meteoroid

What is the command within your "folder.bat" file ? 

PamW
Alteryx Alumni (Retired)

You would use the following command to run it:

 

folder.bat c:\temp\MyFolderName

The batch script contains the following where %1 is the first input from the cmd line:

 

@Echo off
IF EXIST %1 ( ECHO Folder exists > folder.log) ELSE ( MKDIR %1 && echo Created folder > folder.log )
pamW
sayakm
6 - Meteoroid

Thanks a lot for your prompt reply. That was very helpful. 

sayakm
6 - Meteoroid

I got the sample workflow to work, but for some reason when I plug that to my other workflow, the run_mkdir.bat has the command inside quotations and is not doing anything.

 

for example: "folder.bat C:\myDIr\Test" 

 

When I run the snippet as is in a separate workflow; there is no quotations " " so it is working and creating the folder. Any idea what I might be missing?

sayakm
6 - Meteoroid

Actually I want to create a folder for today's date using DateTimeToday()

sayakm
6 - Meteoroid

I got this. The delimiter was set to zero and so it was messing things up. Its all good now. Thanks.

Labels