Create directory on remote FTP server

I use RouterOS v6.46.8(logn-term).

I write I script to backup locally graph data and then backup it to external FTP server.
I NEED to create automaticaly directory because the name of directory is derived from actual time and date, I WANT to execute a backup of graphs data downloaded from local device.

I use I code like the follow.

# Backup graph data to $LocalSavePath
 ...

# Backup to FTP
# Dir all file in sub-directory $LocalSavePath
:foreach i in=[/file find name~("^".$LocalSavePath) ] do={
  :if ([:len [:find [/file get $i type] "file"]]>0) do={
    :local FileName [/file get $i name]

    :local FTPServerSavePath ($FTPServerSavePathRoot.$DateTimeCode."/".[:pick $FileName [:len $LocalSavePath] [:len $FileName]]
    :set Status 7
    :do {
#      :put ("Testpoint : FTP Status=".$Status)
      :do {
        /tool fetch address=$FTPServerAddres port=$FTPServerPort mode=ftp user=$FTPServerUsername password=$FTPServerPassword upload=yes src-path=$FileName dst-path=$FTPServerSavePath
        :set Status -1
       } on-error={
        :set Status ($Status-1)
        :put ("Testpoint : FTP Status=".$Status)
        :delay 10
       }
     } while ($Status>0);
    :if ($Status<0) do={
      :put ("Testpoint : FTP OK")
     } else {
      :put ("Testpoint : FTP Error")
     }

   }
 }

Where for example:
$LocalSavePath = “uSD/Report/”
$FileName = “uSD/Report/graph/cpu/daily.gif”
$FTPServerSavePathRoot = “Router_Report/”
$DateTimeCode = “20201130-1023” (Deriverd from Time & Data at backup moment)
The result is:
FTPServerSavePath = “Router_Report/20201130-1023/graph/cpu/daily.gif”

The folder “20201130-1023” do NOT EXIST, and I CANNOT create it manualy, because the name was created on the fly.
And the fecth now respond failed to copy the file.

If I log-in to the FTP server from a Windows Client with the SAME username and password used in script I can creare folders.
Then the script can make the upload, so NOT is a problem of config, so NOT is a problem of device settings and permissions.

As described in my forum post http://forum.mikrotik.com/t/super-easy-script-to-create-dir/145032/1
So as fecth create local destination folder if not exists when DOWNLOAD. It CAN create directory path if not exist when UPLOAD a file to a remote server.
Because there in NOT another method in Mikrotik language script to create folder.


I ask to Mikrotik if they can implement this simple thinks.

If similar requests will be from users, then we will check on how to implement such a feature Create a directory on the remote FTP server, in the future.

How many people think this is a good think ?

+1 !

Or you can use an FTP server that automatically make the directory if its missing and the user has create directory permission.

  1. FTP client, not server.
  2. Why use another device to do something that the Mikrotik Router can DO ?
  3. If the name of directory was created in the Mikrotik script, by date and time, how can know the other device with FTP Client that name?

But why you deplete time without take the easy path?

Set the name of the file directly like
“20201130-1023-graph-cpu-daily.gif”
and you solve.
You have “indexed” images based on date and time,
and you do not have thousand of images called daily.gif…