Community discussions

 
bestefan
just joined
Topic Author
Posts: 17
Joined: Fri Nov 21, 2008 9:23 am

deleting files with the sam extension

Mon Feb 07, 2011 9:44 am

hi,

:foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] ".rsc"]]!="nil") do={/file remove $i}}
:foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] ".backup"]]!="nil") do={/file remove $i}}

this script remove all rsc and backup files in Mt 3.x. Working nice.
But, in 4.x remove only .rsc, and the .backups are left over.
Any idea, how can i fix it?

Thanks, bestefan
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: deleting files with the sam extension

Mon Feb 07, 2011 12:42 pm

on 5.0rc8:
/file remove [find type="backup"]
/file remove [find type=".rif file"]
have to check what type you want to find before.

this can be done this way as /file remove command supports multiple arguments.
 
ik3umt
Member Candidate
Member Candidate
Posts: 247
Joined: Tue Jul 08, 2014 3:58 pm

Re: deleting files with the sam extension

Thu Sep 27, 2018 6:03 pm

janisk :

/file remove [find type=".rif file"] is OK

But what if I have to delete all .rif files that are into a directory ? Which syntax ?

P:S: I mean ONLY the .rif files that are inside a particular directory, not other .rif files

Who is online

Users browsing this forum: No registered users and 14 guests