Hello everyone. I have a requirement that I need to be able to look at a given directory, and get a list of all of the files + folders in that directory.
Unfortunately the Directory command tool only shows files (if anyone knows how to get it to show just directories please let me know!).
Because of this limitation I was planning on using a run command to simply produce the outputs of a given directory command. However I cannot seem to get alteryx to 'read back' the output of the directory command.
Attached is my current example workflow (very simple workflow to show an example of the problem i'm having). Does anyone have any ideas on how to get this function to work correctly?
Thanks!
Solved! Go to Solution.
Bunkerly to the rescue again! Okay so as always I have a few questions for you here :-) It looks like are building the commands for a .bat file and somehow storing it SOMEWHERE.... and then the command line is using the pushd command to change the directory to the .bat file you just made, then running the dir command, and then using the popd command to get back to the original directory...
You union statement produces the following commands...
pushd "%~dp0"
dir /B "I:\Projects\Brandon\AlterYX Workflows" > dirlist.txt
popd
In my past experience with bat files, if you had a batfile in a directory called c:\mybatfiles\MyBat.bat and you input that variable %~dp0, it would actually resolve too c:\mybatfiles (the full directory of the bat file location). However I can't see where you are making a bat file in your code so I am bit confused :-)
I appreciate your help again as always!
Thanks for the additional info!
The batch file is written within the RunCommand tool:
This is then executed:
And finally the results are read as a flat file:
This is far and away my favourite trick with the Run Command tool as you can pretty much do anything this way (in a past life used it to access financial data for analytics)
Oh my god I just realized what you were doing with the %temp% directory.
This is a GENIUS solution I am going to abuse this all over the place :-)
Thank you very much for your help!
One more follow up question for you!
Your method is awesome and extremely helpful, but it will generate quite a bit of temp folder paths that aren't needed. Do you generally just run a clean up tool on your server on some schedule to clean out your temp folder?
Thanks!
Individual %Temp% directories are created for each run, and Alteryx cleans them up automatically at the end of your session.
As @rdoptis says the temp dir gets cleaned up, as long as you dont create sub folders I think.
Think only cleaned complete when you close Alteryx but might be more frequent
Hi thanks for the solution how do i take the output into a select tool as i need to get just the latest foldername (not filenames or old folders)
thanks