how to send file in script not based the file name ?

Hi all, sorry maybe what i’m asking is a bit weird in mikrotik i have 2 file :
file.lg.0.txt and file.lg.1.txt, is there any way to send these files to email but with not option using the file name, i mean using some regular exp like in linux file=“file.lg.*” so with something like that it will send those 2 files(file.lg.0.txt and file.lg.1.txt) in one time.

I have tried using global command find, like this :

/tool e-mail send to="xxx@xxx.com" subject="blabla" file=[:find "file.lg.*", -1]

it’s not work, and honestly i don’t know to much about “-1” i’ve just follow it like in wiki and is it maybe i need to combine it with other global commands or there is another way about this.
Thank’s a lot and sorry about this question. :slight_smile:

That will not work, but you could loop through files found via a regex and send each one in a separate email in one script.

Thank’s for your reply fewi :slight_smile: , if you don’t mind could you please explain more detail about “loop through files found via a regex and send each one in a separate email in one”, is it will be have 2 email in my inbox later or what ?. An example will very help me.

Sorry about this.

# find all files that have a name starting in . these are returned as references to the object
:foreach FILE in=[/file find where name~"^file.lg"] do={
# get the file name of that object
   :local FILENAME [/file get $FILE name]; 
# email that file
   /tool e-mail send to="xxx@xxx.com" subject="blabla" file=$FILENAME;
}

Thank’s fewi, it’s very help me out.