Super-Easy script to create dir

I found 4 super-easy, it may also customized, scritp to create a full path of a folder.

  • NO need of FTP service enable
  • NO need of Firewall config
  • NO need of User\Password config
  • NO need external scritp
  • May be easy included in other script


{
:local CreateDirNewPath "NewDir/NewSubDir"
:do {
  /tool fetch address=127.0.0.1 port=443 mode=https src-path="NotExist" dst-path=($CreateDirNewPath."/NotExist")
  /file remove ($CreateDirNewPath."/NotExist")
 } on-error={ }
}



{
:local CreateDirNewPath "NewDir/NewSubDir"
:do {
  /tool fetch https://127.0.0.1/NotExist dst-path=($CreateDirNewPath."/NotExist")
  /file remove ($CreateDirNewPath."/NotExist")
 } on-error={ }
}

This is if you not want “status:failed” in terminal.

{
:execute {
  :local CreateDirNewPath "NewDir/NewSubDir"
  :do {
    /tool fetch address=127.0.0.1 port=21 mode=ftp src-path="NotExist" dst-path=($CreateDirNewPath."/NotExist")
    /file remove ($CreateDirNewPath."/NotExist")
   } on-error={ }
 }
}

This if you can use global variable

{
:global CreateDirNewPath "NewDir/NewSubDir"
:execute {
  :do {
    /tool fetch address=127.0.0.1 port=21 mode=ftp src-path="NotExist" dst-path=($CreateDirNewPath."/NotExist")
    /file remove ($CreateDirNewPath."/NotExist")
   } on-error={ }
 }
}

I suggest to Mikrotik to correct also the scritp to https://wiki.mikrotik.com/wiki/Script_to_create_directory

Best regards

…or you can create folder on your desktop and just drop it in your Winbox / Files wherever you want..

Following is SUPER easy way of creating a dir using Terminal

/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.

Make and delete a backup, in the wanted directory.?

@satman1w: This is a method to create it automaticaluy via scritp, or you want that the router call you when it need to create a directory ?

@mozerd: I test the method /ip smb shares on RouterOS v4. and it CANNOT create new sub-folder like NewDir/NewDir2/NewDir3/ in one command. Can you try.

@bpwl: Why write not wanted data, to next delete ?

WHY mikrotik not implement a full set of command to manage file ?
Like copy file, move file, copydirectory, move directory, create directory, etc.

WHY ???

@luca1234567
You are 100% correct … I am not able to create new sub-folders like described … no problem with root folders.

Use winscp to create folder/sub folder?

@CZFan

I repeat:

@satman1w: This is a method to create it automaticaluy via scritp, or you want that the router call you when it need to create a directory ?

I repeat:

@satman1w: This is a method to create it automaticaluy via scritp, or you want that the router call you when it need to create a directory ?

[/quote]

You’re right, but I never had a need to create folders dynamically on Mikrotik router… When that will happen, I will definitely use one of your scripts.
:slight_smile:

regards

I made a better script here, instead of using on-error, the tool fetch and the need to leave http(s) service acrive:
http://forum.mikrotik.com/t/mkdir-function-for-easy-folder-creation/132775/1

Seriously, please PLEASE add directory creating function to ROS 7. What’s so complicated about this?
Having to use all these workarounds is just DISGUSTING! All these topics should not have even existed to start with…

If scripting support is full removed, no one problem coming out using the router as router and the switch as switch…

If is so disgusting, use another vendor with routers and switches full of scripting support.