How to copy file ?

Hello,

I’m new to MikroTik and ROS, so this is probably lame question. How to copy file using script? I want to make copy of log file located on microSD, but I don’t know how to do this :frowning:

Regards, Grzegorz.

There is no functionality for directly copying a file. If the source file size is under 4096 bytes, you can use something along the lines of the below structure to first read the file into a variable, and then create a new file and set its contents to that variable. Variables are restricted to 4096 bytes so anything larger will not work.

:local sourceFile "test.txt";
:local destinationFile "test2.txt";

:local buffer [/file get [/file find name="$sourceFile"] contents];
/file print file=$destinationFile;
/file set "$destinationFile" contents="$buffer"

@fewi
Thanks for your quick answer. Unfortunately, file size is bigger than 4096 bytes, so I can’t use variables. I must find different solution of my problem, which is not too big at all :smiley:

Thanks again, Grzegorz.

To copy/rename bigger files I use fetch (x example to copy firmware among RB):


 fetch address=192.168.83.23 src-path="routeros-mipsbe-5.25.n
pk" user=root password=m1kr0t1k dst-path="routeros-mipsbe-5.25.ori" upload=yes mode
=ftp