How to add folders by command line only (without GUI)

I want to be able to add folders to by synced using the command line (Linux) rather than the web GUI. I would prefer to do it in a bash shell in a terminal if possible.

Specifically, what I want to do by command line is accomplish the same action that the “+ Add Folder” button at the bottom of the left side of the web GUI performs.

(Can I also edit a folder by command line? If not, the option in this case is to edit the config file directly.)

So far I only found this related question:

How to create the sync folder without UI (FolderActivity) correctly - Development - Syncthing Community Forum

That wasn’t helpful to my current question.

1 Like

Shut down syncthing, modify config file, start syncthing.

1 Like

That’s what I tried and I haven’t been able to get it to work. But from your answer, I see that it should work, so I’ll keep trying. I will report back.

Did it work out? Trying to achieve programmatic folder addition myself too…

I edit config.xml on a regular basis, so yes, adding folders this way is definitely possible, as long as you know how to modify the XML file programmatically.

1 Like

Yes, it is working perfectly for me. I use a bash script that updates multiple devices.

so you guys are approaching this via direct config file creation/editing? I just tested the REST API method - seems a little more “proper” to me and it works very well, so I am going with this route instead.

1 Like

on another note - there are plenty of Ansible playbooks to potentially simplify it further too…

That interests me a lot, and I’m hoping to find time to explore the Ansible approach to managing Syncthing clients soon. I look forward to reading anything you can share on that topic.

well, have a look at the Ansible docs here

and this role looks interesting

this role is a bit old and simple. but might work for basic stuff. it has some slightly more touched up forks too

and another role which looks interesting is here

I am only getting started with all of the above so cannot say which works for what but they seem like a decent start…

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