Creating a folder on FTP

I ask for help with the script. I want a folder with the device name to be created on FTP. But an error occurs: failure: FTP server said: 550 File unavailable/inaccesable (/tool/fetch; line 31)
There are rights to FTP, everything works without creating a folder.


Backup Mikrotik configuration

:local tmpdate [/system clock get date];
:local tmpfw [/system/routerboard get current-firmware];

We set variables and parameters for access to FTP

:local myname [/system/identity get name];
:local fname ($myname.“$tmpfw$tmpdate”);
:local bname ($myname.“$tmpfw$tmpdate.backup”);
:local ename ($myname.“$tmpfw$tmpdate.rsc”);
:local ftpuser “ftpuser”;
:local ftppass “password”;
:local ftpaddr “IP”;
:local backupdir $myname; # Papka po FTP s imenem ustroystva

Uploading settings

/system backup save name=$fname;
:delay 10;
:export file=$fname;
:delay 10;

\

Checking if the folder exists

:if ([/file find name=$backupdir] != “”) do={
:log info “Backup file $backupdir exists.”;
} else={
:log error “Backup file $backupdir does not exist.”;
}

\

Create a directory if it does not exist

/tool fetch address=$ftpaddr user=$ftpuser password=$ftppass port=21 mode=ftp src-path=“.” dst-path=“$backupdir/”;
:if ([:len [/file find name=“$backupdir”]] = 0) do={
:log error “Failed to create directory $backupdir on FTP.”;
} else={
:log info “Directory $backupdir exists or was created successfully.”;
}

Uploading the configuration to FTP

/tool fetch address=$ftpaddr src-path=$bname user=$ftpuser password=$ftppass port=21 upload=yes mode=ftp dst-path=“$backupdir/$bname”;
:if ([:len [/file find name=$bname]] = 0) do={
:log error “Failed to upload $bname to FTP.”;
} else={
:log info “Successfully uploaded $bname to FTP.”;
}

Uploading the configuration to FTP

/tool fetch address=$ftpaddr src-path=$ename user=$ftpuser password=$ftppass port=21 upload=yes mode=ftp dst-path=“$backupdir/$ename”;
:if ([:len [/file find name=$ename]] = 0) do={
:log error “Failed to upload $ename to FTP.”;
} else={
:log info “Successfully uploaded $ename to FTP.”;
}

#Udalyayem fayly s ustroystva

/file remove $bname;
/file remove $ename;