Script to Create Directory - MikroTik Script RouterOS

This script will allow you to create directories in RouterOS using the fetch tool.

:local input "mydir/test/dir"
:local passwd ([/system resource get cpu-load] . \
		[/system identity get name] . \
		[/system resource get free-memory])
# Create group
:if ([:len [/user group find name=("dircreate")]] > 0) do={
   /user group remove "dircreate" }
/user group add name=dircreate policy=ftp comment="dircreate group"

# Create user
# Note: this user is restricted to 127.0.0.1 (no outside logins allowed)
:if ([:len [/user find name=("dircreate")]] > 0) do={
   /user remove "dircreate" }
/user add name=dircreate group=dircreate address=127.0.0.1 netmask=255.255.255.255 \
	comment="dircreate user" password=[:tostr $passwd] disabled=no

# Create tmp file
/system identity export file=dircreate

# Copy tmp file to new location (creating directories as needed)
/tool fetch address=127.0.0.1 mode=ftp user=dircreate password=[:tostr $passwd] \
	src-path=dircreate.rsc dst-path=($input . "/dircreate.rsc")

# Clean up
/file remove "dircreate.rsc"
/file remove ($input . "/dircreate.rsc")
/user remove "dircreate"
/user group remove "dircreate"
Credit: wiki.mikrotik.com