Hotspot Users

Bulk Change Data Limit by Comment — 7

Sets a new total data limit (limit-bytes-total) for all hotspot users that share the same comment.

MikroTik Version

RouterOS 7

# EN: Comment of the batch to modify | AR: كومنت الدفعة المراد تعديلها
:local targetComment "change here";
# EN: New total limit in BYTES, as a number. Example: 356515840 = 340MB, 1073741824 = 1GB, 0 = unlimited
# AR: الحد الجديد بالبايت كرقم. مثال: 356515840 = 340 ميجا، 1073741824 = 1 جيجا، 0 = بدون حد
:local newTotalBytes "change here";

# EN: Safety check | AR: حماية من عدم تعديل المتغيرات
:if ($targetComment = "change here" || [:typeof $newTotalBytes] != "num") do={ :error "Edit the variables first" }

# EN: Loop over all users with this comment | AR: المرور على كل المستخدمين بهذا الكومنت
:foreach u in=[/ip hotspot user find where comment=$targetComment] do={
    # EN: Apply the new data limit | AR: تطبيق حد البيانات الجديد
    /ip hotspot user set $u limit-bytes-total=$newTotalBytes
}