syncthing cli folders add

I have been searching high and low, but cannot find the answer I am looking for. Perhaps it is not possible.

I am trying to use the syncthing cli command to add a folder with the label and the path. I see I need to add the id, but how do I get syncthing cli to auto generate the id as it does in the webui?

syncthing cli config folders add --id "" --label "Label Name" --path "C:\Users\Public\Documents\Label"

It doesn’t have that functionality, you need to supply your own random string. On Unix I’d grab the first part of an UUID, because that’s the first random string generator that comes to mind;

% fid=$(uuidgen) ; fid=${fid%%-*}
% echo $fid
3A9F75F7

You’re on Windows so that won’t run, but perhaps Powershell has something similar. There’s also an API in Syncthing to ask for a random string, which is in fact what the GUI does. Perhaps it’s easy enough to call that in Powershell:

% curl -kH x-api-key:LCG...6UF https://localhost:8384/rest/svc/random/string?length=10
{
  "random": "WTq5LSPhAA"
}

That gives you the same randomness and character set the usual folder ID uses, except the GUI makes it lower case and it’s lacking the dash in the middle for readability. I could write some shell hack to add that, but it won’t help you so I’ll stop here and hope some Windows person chimes in. :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.