I have this script for copy one file
Code: Select all
:local buffer [/file get [/file find name="flash/tmp1/ubuntu_rsa"] contents]
/file print file=("tmp1/ubuntu_rsa"."\00")
/delay 1s
/file set tmp1/ubuntu_rsa contents="$buffer"
how to modify it so that it also copies all files from folder A to folder B?
I asked the chatbot Mikrotik and GPT, they gave something similar, but it still doesn’t work
Code: Select all
# Define source and destination directories
:local sourceDir "/source-directory/"
:local destDir "/destination-directory/"
# Get a list of all files in the source directory
:local fileList [/file find where name~"$sourceDir"]
# Loop through each file in the source directory
:foreach file in=$fileList do={
# Get the file name
:local fileName [/file get $file name]
# Read the contents of the file
:local fileContents [/file get $file contents]
# Define the destination file path
:local destFile ($destDir . [:pick $fileName [:len $sourceDir] [:len $fileName]])
# Write the contents to the destination file
/file print file=$destFile contents=$fileContents
}