Alteryx Designer Desktop Discussions

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

Using directory to get Folder Names only and not subfolders or files

wonka1234
10 - Fireball

Hi,

 

How can I pull folder names from a directory? I do not want the subfolders or files names

I also want the folder names even if they do not contain a file.

 

Thanks.

15 REPLIES 15
FinnCharlton
13 - Pulsar

You can do it by parsing the folder names from the results of the directory tool. This workflow is one way to do it, although it isn't dynamic. 

FinnCharlton_0-1673883643211.png

To make it dynamic you could turn it into a macro, where the input to the directory tool also changes the RegEx tool

BS_THE_ANALYST
14 - Magnetar

@FinnCharlton I was thinking along these lines. However, if you have a folder in your directory which doesn't contain files, the directory tool will not output this particular folder as a result (using this workflow approach). Thus, this won't display all folders as requested.

 

It would be nice to see something where it display the folders and if there isn't any files, it displays Null under 'FileName'.

wonka1234
10 - Fireball

thanks it works.. would there be any scenario where this wouldnt get all folder names? It seems like I am not getting all of them. Only 50/200 are being returned..

BS_THE_ANALYST
14 - Magnetar

@wonka1234 Do the folders, that are not being returned, contain files? 

wonka1234
10 - Fireball

@BS_THE_ANALYST  Correct! I do want the folder names even if there are no files contained in a subfolder.

FinnCharlton
13 - Pulsar

If you need folders without files then I don't think the directory tool can help you. In this case you'll need to use the "Run Command" tool to display all the folders in a directory. Using the dir command along with the d attribute will just show you folders without files or subfolders. There is plenty of online material around this - here is a decent intro to the Run Command tool: 

https://carlscholl.com/2022/02/21/how-to-use-alteryx-and-run-command-functionality-to-batch-copy-a-t...

And here is the documentation for the dir commnad:

https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir

HomesickSurfer
12 - Quasar

Hi @wonka1234 

 

See attached.  Failing this, you can use the Run tool and config to use a .bat to list folders

HomesickSurfer_0-1673885297635.png

 

binay2448
11 - Bolide

Please find attached solution, May be it will help you to find you answer. Just run the app and select the folder location and run.

binay2448
11 - Bolide

Use this updated solution, ignore last one.

Labels