It is possible to get sorted array (by name or creation-time) with /file find ?
I need to delete recent n files
Code: Select all
[admin@MikroTik7-Test] > /file print detail where name~"MikroTik7-Test_.+\\.backup\$"
0 name="MikroTik7-Test_2021-09-14_132825.backup" type="backup" size=72.9KiB creation-time=sep/14/2021 13:28:25
1 name="MikroTik7-Test_2021-09-14_132104.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 13:21:04
15 name="MikroTik7-Test_2021-09-14_142900.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 14:29:00
3 name="MikroTik7-Test_2021-09-14_132205.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 13:22:05
4 name="MikroTik7-Test_2021-09-14_132340.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 13:23:40
5 name="MikroTik7-Test_2021-09-14_132455.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 13:24:55
7 name="MikroTik7-Test_2021-09-14_133044.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 13:30:44
8 name="MikroTik7-Test_2021-09-14_115638.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 11:56:38
16 name="MikroTik7-Test_2021-09-14_142715.backup" type="backup" size=72.8KiB creation-time=sep/14/2021 14:27:15
# Part of my script
:local bkFilesArr [/file find name~"MikroTik7-Test_.+\\.backup\$"]
:local bkFilesLen [:len $bkFilesArr]
:log info "bak [6.2] backups: $bkFilesLen"
:local i 0
:foreach file in=$bkFilesArr do={
:log info ("bak [6.3.$i] $file " . [/file get $file name])
set $i ($i + 1)
}