Community discussions

MikroTik App
 
aguntukk
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 10, 2014 2:37 pm

Need to remove space..Help

Sun Apr 28, 2019 10:22 am

I have named my simple queue rules with spaces , Like "Rajesh Bose",
i wanna script to remove all these spaces from the names auto .
is it possible
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Need to remove space..Help

Sun Apr 28, 2019 8:22 pm

This should remove all spaces from /queue tree names
:foreach i in=[/queue tree find] do {
	:local name [/queue tree get number=$i name]
	:local newname
	:for j from=0 to=([:len $name]-1) do={
		:local tmp [:pick $name $j]
		:if ($tmp !=" ") do={
			:set newname "$newname$tmp"
		} 
	}
	/queue tree set name=$newname numbers=$i
}
If you like to run it directly from cli (telnet/ssh/winbox cli) add []. So you can cut and past this:
[
:foreach i in=[/queue tree find] do {
	:local name [/queue tree get number=$i name]
	:local newname
	:for j from=0 to=([:len $name]-1) do={
		:local tmp [:pick $name $j]
		:if ($tmp !=" ") do={
			:set newname "$newname$tmp"
		} 
	}
	/queue tree set name=$newname numbers=$i
}
]

Who is online

Users browsing this forum: ramin110 and 30 guests