: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"
and it works great,
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
# 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
}
@Liiina Did you try how your current copy script works with large files (eg. 1GB file size)? See here for possible workaround if you gonna go into this endeavour.
thanks for the answers, but i don’t need to copy large files, just three dozen files witch configurations, macros, rsa keys, etc. the largest file does not exceed 1.5 KB. enabling external services is not allowed.
i would be very grateful if someone rewrote my single file script into a proper workflow with
:foreach file in=$fileList do={
..
}
Are you convinced that a forum is a place where dozens of users just wait on the couch, tapping their feet impatiently, waiting to solve others’ problems?