Hotspot Users

Bulk Change Hotspot User Comment โ€” 6

Finds every hotspot user that has a given comment (usually a batch/card series name) and replaces it with a new comment.

MikroTik Version

RouterOS 6

# EN: Old comment to search for | AR: ุงู„ูƒูˆู…ู†ุช ุงู„ู‚ุฏูŠู… ุงู„ู…ุฑุงุฏ ุงู„ุจุญุซ ุนู†ู‡
:local targetComment "change here";
# EN: New comment to apply | AR: ุงู„ูƒูˆู…ู†ุช ุงู„ุฌุฏูŠุฏ ุงู„ู…ุฑุงุฏ ุชุทุจูŠู‚ู‡
:local newComment "change here";

# EN: Safety check - stops if variables were not edited | AR: ุญู…ุงูŠุฉ - ูŠุชูˆู‚ู ุงู„ุณูƒุฑุจุช ุฅุฐุง ู„ู… ูŠุชู… ุชุนุฏูŠู„ ุงู„ู…ุชุบูŠุฑุงุช
:if ($targetComment = "change here" || $newComment = "change here") do={ :error "Edit the variables first" }

# EN: Loop over all users that have the old comment | AR: ุงู„ู…ุฑูˆุฑ ุนู„ู‰ ูƒู„ ุงู„ู…ุณุชุฎุฏู…ูŠู† ุงู„ุฐูŠู† ู„ุฏูŠู‡ู… ุงู„ูƒูˆู…ู†ุช ุงู„ู‚ุฏูŠู…
:foreach u in=[/ip hotspot user find where comment=$targetComment] do={
    # EN: Set the new comment | AR: ูˆุถุน ุงู„ูƒูˆู…ู†ุช ุงู„ุฌุฏูŠุฏ
    /ip hotspot user set $u comment=$newComment
}