Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Configure Run Command tool to move a file

AndrewW
11 - Bolide

I have a number of files in a directory, some of which I'll process, some of which I won't, but all YXDBs. Once all of the files I want to process have been processed then I want to move them to a different directory (or maybe delete, still TBC). I can do this using the command prompt.

 

The difficulty I'm having is how to run the command prompt, how to configure the Run Command tool. Apparently it needs either a Write Source or Read Results, I can't think what these could be to run a command in the command prompt.

 

I'll actually be generating the list of files to move into a list and am comfortable using a macro to alter the Command Arguments to dynamically load the command line details. What I don't know how to do is to get actually get the Run Command configured.

 

Note I've seen this prior question on a similar note, http://community.alteryx.com/t5/Data-Preparation-Blending/Using-Run-Command-to-Move-files/m-p/8958, but I prefer to do the Run Command mid-workflow and not use the Events if possible.

 

 

Frustratingly I'm unable to upload my 19kb screen shot of the current Run Command configuration so to describe I have entered "cmd" in the Command section and the correct arguement in the Command Arguments [Optional] section, which gives the error "Either an Output connection or Input Connection is required"

 

 

20 REPLIES 20
michael_treadwell
ACE Emeritus
ACE Emeritus

Andrew, scroll down and check my post in this thread to get a better explanation of what is going on in the Run Command tool and how it should be configured: http://community.alteryx.com/t5/Data-Preparation-Blending/Run-a-python-script-in-Alteryx/m-p/10999#M...

 

It sounds like you have most of the work done if you can already accomplish the file move via the command line.

 

In your case, you don't necessarily need Write Source or Read Results but since Alteryx requires at least one you might consider having them write dummy .txt files.

s_pichaipillai
12 - Quasar

Andrew

Try this one too. this will generate the Move comman batch file at temp path and move the files to the spcefied firectory

i enabled full path in Input configuration

 

AndrewW
11 - Bolide

Thanks for the response Michael. Not there yet and I'm confused why. I created a Dummy.csv as my Input (Write according to the Run Command tool) and that allowed it to work - ot at least the cmd prompt opened. The Command Arguments weren't moved into the command prompt. It actually does nothing apart from open the command prompt and then spinds in the Run Command icon on the workflow until I manually cancel. The command prompt remains open but doing nothing during this time. 

 

I restested and the 'argument' entered should work, at least it does when I enter into the command prompt opened by Alteryx when trying to Run Command. Is this anything you come across before?

Any ideas?

AndrewW
11 - Bolide

That does work, many thanks for that. I would really appreciate it if you could explain what is actually happening at each step. I understand the formula field created the Move statement and where to move the file. I don't understand what happens in the Command string after the ">" sign where it ends with MoveCommand.txt.

 

In addition what is the 'Write Source' %/temp%\MoveFiles.bat? I can't see if/where that was created in the script?

 

Thanks again.

s_pichaipillai
12 - Quasar

Sure i can explain that

here is the actual workflow Screenshot

Delete.PNG

1. I Grab the Path of my file, so i can use this path and file name for my Move Command

2. I Used here Block Until DOne tool, so that the move command will wait until the actual file process

3. i am creating the Move command ""Move"+" "+[SourceFile] +" "+[Processed]+ ' > "' + [Engine.TempFilePath] + '\MoveCommand.txt"'

4. here every workflow execution the bat fiile will be created in Engine temp path folder you can see it under "C:\ProgramData\Alteryx\Engine" folder

5.After the > sign i am taking the output of move command to Movecommand.txt (kinda log file).. here it will log the message whether it moved or errored . this case i logged as "1 file(s) moved."

6.%/temp% is to specify the Engine temp path

you can the files Bat, log file etc here. see the screen below

engine.PNG

 

does that helps ?

 

 

AndrewW
11 - Bolide

I've got it now, thanks for the explanation. The Run Command tool is creating the batch file in the "Write Source [Optional]" area, with the bat file being the script written in the formula tool and being passed into the Run Command tool.

 

The Run Command tool then executes the batch file it has just created. This batch file creates the MoveCommand.txt file which is then referenced in the Run Command "Read Results [Optional]" area.

 

Good work :-)

s_pichaipillai
12 - Quasar

you got it :-)

its good that always log the run command output in a file . most of the time run  command tool will say error exit code etc. but not the actual error . becasue we are running external program 

tom_montpool
12 - Quasar

Just a quick note...if you're running a batch file multiple times, you can switch the > operator to a >>.

 

The > operator creates a new file each time.

The >> either creates a new log OR appends to an existing one.

 

Play safe.

ronh_allaboutgis
6 - Meteoroid

Hi Tom,

 

This option works well when you want to create separate files containing the batch results - any ideas how to append the batch results to one large file when the results all have the same format?

 

Thanks, Ron

Labels
Top Solution Authors