I am trying to get files from an SFTP server. Because I need to write log for each file, I get one file at a time. Below is about my steps:

  • pub.client.sftp:ls
    (to find how many files would be download)
    (for the service, we will get a list “dirList”)
  • loop /dirList:
    • pub.client.sftp:get
    • write log

When I do “pub.client.sftp:ls”, I will get name of both files and directories. However,“pub.client.sftp:get” cannot get directory and will return an error instead.

How can I distinguish the file or directory? There is a parameter “permission” in dirList. Could I use “permission” to do that?

Thank you very much!

webMethods IS version:
Java Version: 1.8.0_202 (52.0)


This is the logic I use for these situations:

In my experience, the dirList/permissions string begins with “d” for the directories and “-” for the files, so the BRANCH with the filter %dirList/permissions%=/^-.*/ only runs for files, and the directories are skipped.

One quick note: the pub.documents:sortDocuments in the screenshot required in general. I happen to need it for the specific service I grabbed the snippet from.

Elaborating on “what type of entry is it”, can use this:

BRANCH on '/dirList/permissions'
../^d/: MAP (Directory)
../^|/: MAP (Symlink)
../^-/: MAP (File)
..$default: MAP (Other)

We use this in our own service that wraps pub.client.sftp:ls and adds a couple of other commonly needed features (support for regex, mimic the Unix ls command -a and -A options, sort, limit the number of entries, etc)

1 Like

Hi all,

Thank you for your replying.
I have tried these solutions and it works successfully!