Code: Select all
$mkdir some/new/folder
It builds on this code found on the official Wiki, which uses FTP via /tool fetch to create the directory tree. This function handles cases like the FTP service being disabled, cleans up after itself even if an error occurs, and is easy to install.
The code and instructions are available on GitHub.
Here's the script itself: https://github.com/phistrom/routeros-mk ... nction.rsc
or here's a snippet you can copy and paste in the terminal to easily create the function and a scheduler entry that runs on startup to make sure that $mkdir is always available.
Code: Select all
# if you trust strangers on the internet
# for extra safety, the commit in the below URL is pinned to da45ff1987aa6723559aee8bf344b341efd31393
{
:local result [/tool fetch \
url="https://raw.githubusercontent.com/phistrom/routeros-mkdir/da45ff1987aa6723559aee8bf344b341efd31393/persist_create_mkdir_function.rsc" \
as-value output=user];
:local script [:parse ($result->"data")]
$script;
}
Code: Select all
:global mkdir;
Code: Select all
$mkdir
Script Example:
Code: Select all
:global mkdir;
# ensure backups directory exists
$mkdir "disk1/backups";
/system backup save name=disk1/backups/backup;