SFTP Create Subdirectory

Hello,

it seems that the SFTP Workflow Plugin does not create subdirectories on the remote server. How can I create automatically subfolders on the remote server while I only have the possibility to connect through SFTP?

Best regards
Thomas

Well, that plugin is just invoking WinSCP in the background. So you can make use of the WinSCP executable that is installed along with the plugin to pass commands to the remote server.

The executable should be located here:
C:\Program Files (x86)\Common Files\Objectif Lune\PlanetPress Workflow 8\Plugins\SecureFTP

So in an External Program action, you’d want to set the executable file to

C:\Program Files (x86)\Common Files\Objectif Lune\PlanetPress Workflow 8\Plugins\SecureFTP\WinSCP.exe

and the Parameters to something like this:

/log="C:\WinSCP.log" /ini=nul /command "open sftp://%{username}:%{password}@%{host}/ -hostkey=""%{hostkey}""" "mkdir %{directory}" "exit"

If you’re having trouble with any of that (especially the host key), you can open WinSCP directly, make a connection manually, then go to Session > Generate Session URL/Code. This will create a prefilled command line argument string based on your current connection.

Just copy/paste what it generates and replace the necessary parts with variables, as well as inserting the mkdir command as above.

1 Like

That is a very good hint. Thank you for that. I did not know about the WinSCP feature generating command line string. I will give it a try.

Thanks again. It works like a charm.

Note: It is not possible to create multiple subdirectories (/sub1/sub2/sub3). You have to create one sub after the other. But that is possible in one command line string.

Example:

/log="C:\WinSCP.log" /ini=nul /command "open sftp://%{username}:%{password}@%{host}/ -hostkey=""%{hostkey}""" "mkdir /sub1" "mkdir sub1/sub2" "mkdir sub1/sub2/sub3" "exit"