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"
Solved! Go to Solution.
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.
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?
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.
Sure i can explain that
here is the actual workflow Screenshot
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
does that helps ?
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 :-)
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
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.
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
User | Count |
---|---|
19 | |
15 | |
13 | |
9 | |
8 |