Get all files in a folder as a variable

I'm trying to figure out how to get all the files in a folder as a variable formatted like this


Basically, having multiple file paths as a variable.

Thanks :slight_smile:


1 Like

If you're comfortable using a shell script (and perhaps tweaking the command options to your liking and platform), this worked for me.

  • ls is the command for listing directory contents
  • -1 means one file per line (that's the number "one")
  • -d means show the files in the directory (try without it to see the difference)

Without knowing your objective in doing this, you might find it easier to just use the For Each action with a "The files in directory" Collection:


The full POSIX path of each item in the directory/folder is put into the KM Variable "Local__FilePath" as the For Each Action loops through each item in the directory/folder.