Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Alteryx is here to help you solve your biggest data challenges. Read about the new Virtual Solution Center here.

Help reading folder names, not file names.

Highlighted
9 - Comet

Hi Everyone,

 

I'm looking to get a list of folders within a folder, not files. The issue is that each of those folders contain a ton of files and running the Directory tool including subfiles and piecing the pathnames to the folders takes 5 hours. Putting a small text file in each folder and searching for that specific file name cut that time down to 3 hours but the problem is that the Directory tool in order to go one level down has to search through every single subfolder as well. I would just accept that it takes so long to run, except the folders in the main folder change regularly. Does anyone have a solution?

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Hi @myastarling 

 

You could use Run Command Tool to give you a full list of subfolders using command "dir /ad /b /s"

Then your write the results to a .txt file. dir /ad /b /s > example.txt

 

exampleshot.PNG

 

See example attached. You need to change folder name (on Text Input) and folder locations in the run command tool.

 

Cheers,

 

Highlighted
9 - Comet

I don't understand how to customize this to what I need to do. This is what I did to customize the workflow you provided:

I changed the text input to the folder I want to read the folder names in

Changed the output to a location on my desktop (C:\Users\(my username)\Desktop\runme.bat)

Changed the Command to the same thing as the write source

Created a new .txt file and entered the location in the Input line(selected 'Read as delimited text' and Tab, filenames in first column

 

When I run it, all I get is the contents from the text file I created.

 

 

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

@myastarling 

 

Could you please post at least how you set up the Formula Tool to create the command?

 

Cheers,

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

@myastarling 

Also, you shouldn't create a new text file.

The file is going to be created with the command. You just need to set up the read part as a txt file with no delimiters.

 

Just to be sure: are you using Windows OS?

 

Cheers,

Highlighted
9 - Comet

I was pulled away to a different project and I'm just getting back.

 

I'm using Windows OS. 

So I got this to work for my C drive, but having problems getting it to work with a different drive.

 

Here's what worked for me:

1-Text Input: Changed the Field1 Row1 to C:\Users\[username]

2-Formula: No changes made. The output was New Column

                                                                           cd C:\Users\[username]

                                                                           dir/ad /b /s >tact.csv

5-Select: no changes made

3-Run Command: changed Output to C:\Users\[username]\Desktop\runme.bat

    Run External Program Command: changed to C:\Users\[username\[Desktop]\runme.bat

   Read Results: changed to C:\Users\[username]\tact.csv -- I didn't have a txt option in my file listing, and if I tried to force it, Alteryx returned an error.

   this produced (a) an error: 'NewColumn' is not recognized as an internal or external command, operable program or batch file

                          (b) processed the cd and dir lines

                          (c) produced a listing of folders and sub-folders.

 

To change it to a different drive, I tried changing the path in the original input to that pathname, but it's still returning a list of the contents of my C drive -- what am I doing wrong?

 

Thanks!

 

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Hi @myastarling 

 

Could you please share your updated workflow?

 

You can change the folder names, no problem. 

 

Cheers,

 

 

Labels