Page 1 of 1

Command to create directory?

Posted: Fri Dec 04, 2015 2:15 pm
by midenok
I just don't get it. Isn't there a straight way to create a directory except "shaman dance" that Google suggests?

Re: Command to create directory?

Posted: Fri Dec 04, 2015 2:15 pm
by normis
RouterOS does not have a proper file manager or directory support.
You can use SMB and then make folders from your Windows Explorer

Re: Command to create directory?

Posted: Sat Jan 02, 2016 4:58 am
by stewartpe
ftp into the router, then press ? for a list of commands.
mkdir will be most helpful.

Re: Command to create directory?

Posted: Sun Jul 21, 2019 5:05 am
by jaadu
Create the folder you want on your desktop and drag it in to 'Files' via winbox.

Re: Command to create directory?

Posted: Tue Jul 23, 2019 11:09 pm
by eworm
No idea why the script creates user, group and whatever. Given you have http-ssl service enabled this should suffice:
/tool fetch https://127.0.0.1/ dst-path=path/to/create/xxx
Alternatively use whatever webserver. It creates a file as well, just remove that:
/file remove path/to/create/xxx

Re: Command to create directory?

Posted: Wed Jan 13, 2021 1:49 pm
by Fantomas
No idea why the script creates user, group and whatever. Given you have http-ssl service enabled this should suffice:
/tool fetch https://127.0.0.1/ dst-path=path/to/create/xxx
Alternatively use whatever webserver. It creates a file as well, just remove that:
/file remove path/to/create/xxx

How about using 'dot' in place of 'xxx' like below. This way the website won't be saved as 'xxx' file even if is fetched (adding keep-result=no won't create any directories):
{
# ----- Create directory tree with /fetch -----
# Take note of the 'dot' (or 'space') in place of 'file name',
# this will prevent the fetched website from actually being saved as a file
# even if fetch is successful
:local path "disk1/complex/directory/tree/."
:do { /tool fetch dst-path=($path) url="https://127.0.0.1/"; } on-error={ :put "Script will continue dispite an error"; }
:local otherpath "disk1/some/other/dir/."
/tool fetch dst-path=($otherpath) url="https://www.google.com/"
}

Re: Command to create directory?

Posted: Wed Jan 20, 2021 3:14 pm
by eworm
A file name containing just a dot represents the current directory. So you create the directory and try to overwrite it with a file... This results in an error:
  status: failed

failure: cannot open file
With your code you have to catch and ignore the error.
I prefer my clean solution. 😜

Re: Command to create directory?

Posted: Fri Mar 10, 2023 2:37 am
by Limen
In case if anyone is still wondering.
Just create a SMB share and it will create a folder.

Re: Command to create directory?

Posted: Fri Mar 10, 2023 8:00 am
by Amm0
Or mount the disk use the ROSE support with NFS, etc too.

But yeah some "/file add" would be much easier on the device. They really are missing the analog of UNIX "touch". But it doesn't come up that much since you start running into parsing/editing are also lacking & commands that output files allow a path.

Re: Command to create directory?

Posted: Fri Mar 10, 2023 12:29 pm
by mozerd
The flowing will do it for you
/ip smb shares add name=sharethis directory=moab
/ip smb shares remove [find name=sharethis]
The 1st directive will create the directory while the 2nd directive will remove the share that is not needed.

Re: Command to create directory?

Posted: Wed May 31, 2023 12:25 pm
by berisz
Since the ROS Release v7.9 2023.05.02.:
> /file/add name="/MyFolder/MySubFolder/MyFile.txt" contents="Hello MikroTik :)" ;

> /file/print detail where name="MyFolder/MySubFolder/MyFile.txt" ;
  3 name="MyFolder/MySubFolder/MyFile.txt" type=".txt file" size=17 creation-time=may/31/2023 08:45:15 contents=Hello MikroTik :)

> /file/remove numbers="MyFolder/MySubFolder/MyFile.txt" ;

> /file/print detail where name="MyFolder/MySubFolder" ;
  2 name="MyFolder/MySubFolder" type="directory" creation-time=may/31/2023 08:46:05
The first line creates a TXT file, including the folder hierarchy.
The second displays the contents of the File.
The third deletes the File.
The fourth displays the properties of the remaining folder.

Write to existing directory:
> /system/resource/print file="/MyFolder/MySubFolder/ResData.txt" ;       
> /file/print detail where name="MyFolder/MySubFolder/ResData.txt" ;  

(!) The symbol for root ("/") is not consistent.

Re: Command to create directory?

Posted: Wed May 31, 2023 12:38 pm
by rextended
This is a miracle...
So when RouterOS 7.23.5 (long-term) comes out I will be able to start experimenting on how to use it in production...

Re: Command to create directory?

Posted: Sat Jun 03, 2023 12:17 pm
by judoleza
Since the ROS Release v7.9 2023.05.02.:

(!) The symbol for root ("/") is not consistent.
Hello,

an absolutely genuine, perfect post!
Dis is why it is always worthy coming here.

Thank you, colleague in arms!

Re: Command to create directory?

Posted: Tue Jul 04, 2023 12:38 am
by berisz
Since the ROS Release v7.9 2023.05.02.:

(!) The symbol for root ("/") is not consistent.
Hello,

an absolutely genuine, perfect post!
Dis is why it is always worthy coming here.

Thank you, colleague in arms!
Thank you very much colleague! :)

Re: Command to create directory?

Posted: Fri Jul 14, 2023 7:30 pm
by rextended
...