Community discussions

MikroTik App
 
midenok
newbie
Topic Author
Posts: 39
Joined: Fri Dec 27, 2013 5:34 pm

Command to create directory?

Fri Dec 04, 2015 2:15 pm

I just don't get it. Isn't there a straight way to create a directory except "shaman dance" that Google suggests?
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26288
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Command to create directory?

Fri Dec 04, 2015 2:15 pm

RouterOS does not have a proper file manager or directory support.
You can use SMB and then make folders from your Windows Explorer
 
User avatar
stewartpe
just joined
Posts: 15
Joined: Wed Dec 12, 2007 7:49 pm

Re: Command to create directory?

Sat Jan 02, 2016 4:58 am

ftp into the router, then press ? for a list of commands.
mkdir will be most helpful.
 
jaadu
just joined
Posts: 16
Joined: Mon Sep 30, 2013 6:14 am

Re: Command to create directory?

Sun Jul 21, 2019 5:05 am

Create the folder you want on your desktop and drag it in to 'Files' via winbox.
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Command to create directory?

Tue Jul 23, 2019 11:09 pm

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
 
Fantomas
just joined
Posts: 2
Joined: Wed Jan 13, 2021 12:36 pm

Re: Command to create directory?

Wed Jan 13, 2021 1:49 pm

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/"
}
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Command to create directory?

Wed Jan 20, 2021 3:14 pm

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. 😜
 
Limen
just joined
Posts: 4
Joined: Thu Oct 08, 2020 6:49 pm

Re: Command to create directory?

Fri Mar 10, 2023 2:37 am

In case if anyone is still wondering.
Just create a SMB share and it will create a folder.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3169
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Command to create directory?

Fri Mar 10, 2023 8:00 am

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.
 
User avatar
mozerd
Forum Veteran
Forum Veteran
Posts: 871
Joined: Thu Oct 05, 2017 3:39 pm
Location: Canada
Contact:

Re: Command to create directory?

Fri Mar 10, 2023 12:29 pm

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.
 
User avatar
berisz
newbie
Posts: 43
Joined: Tue Dec 12, 2017 12:50 am

Re: Command to create directory?

Wed May 31, 2023 12:25 pm

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.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Command to create directory?

Wed May 31, 2023 12:38 pm

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...
 
judoleza
just joined
Posts: 5
Joined: Sun Jan 17, 2021 8:26 pm

Re: Command to create directory?

Sat Jun 03, 2023 12:17 pm

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!
 
User avatar
berisz
newbie
Posts: 43
Joined: Tue Dec 12, 2017 12:50 am

Re: Command to create directory?

Tue Jul 04, 2023 12:38 am

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! :)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Command to create directory?

Fri Jul 14, 2023 7:30 pm

...

Who is online

Users browsing this forum: baragoon and 20 guests