Question about Get Folder Contents

when I use the Get Folder Contents action I get the same result, no matter if I select contents to list “files” or “files and folders”.

In both options I get a list like this:

But I would like to get only the file names

Is that possible and how?
If not, does anyone have an idea how to extract only the file name from the complete filepath?


A couple different options:

  1. Move it to a variable and use the “substring between” command to find the filename… Since you know the “directory” you can extract after C:\Users\dell\
  2. Move it to a variable and use the “substring” command to find the filename after … Since you know the “directory” you can extract after 14 characters
  3. Move it to a variable and use the “substring between” command to find the filename… If you know the partial “directory” you can extract after dell\



Thanks @jdoering
I used the option of putting the filepath into a variable and then use the replace action on the path+filename:
Replace in element, search for variable “filepath” and replace with “empty”. What is left over it the filename.

Anyway, I am still curious why the standard action “get folder content” doesn’t seem to work as it is supposed to.

@timriewe The action returns full paths in all case. If you have any other folders inside this folder and use options “Files and Folders”, the sub-folders are written in the variable, too. And if you use Files options, only paths to files are written to the variable.
Since you don’t have any folders inside dell\ folder, the results are the same in both cases.

Ok, thanks @ashapkina!

I found another way to extract only the filemane from a filepath of which I dont know the lenght.

My problem was that the filepath is variable within a list of elements.
So it could be any of these:

and I need to extract only the filename “file.pdf”. I did it using the action “split string”.
Split string of the element that contains the complete filepath including filename and store it in a list variable.
Then loop at that list variable storing the list element value in a “filename” variable.
The last item in the list variable (when the loop has finished) is the filename :slight_smile:


@timriewe Tim, I just tried it - works great :+1::grinning: Thank you!

hi can you please post code here.