CIDR to subnetmask text converter

I can’t even get started on this script. :o I hope someone can help me get started.

The files I personally need to be converted don’t use /32 for individual listings, instead just list the main ip address. Thus to make this a universal script for anybody to use it should use two approaches to cater for the suggested scenario.

1. Lines of the document that do not contain “/“ add “/255.255.255.255” to EOL is my thought of how to approach it.
2. All others would be replacements for their subnetmask equivalents such as:
“/32“ to “/255.255.255.255”
“/31“ to “/255.255.255.254”
“/30“ to “/255.255.255.252”
“/29“ to “/255.255.255.248”
“/28“ to “/255.255.255.240”
“/27“ to “/255.255.255.224”
etc.

The files needing conversion are between 1,800 up to half a million listings. Not a practical thing to do manually. :smiley:
My particular purpose is for block-lists to block out net BOTs.

Model: MacPro 2008 (3,1)
AppleScript: 2.8.1 (183.1)
Browser: Firefox 57.0
Operating System: Mac OS X (10.11.6)

I’m afraid I’m not fully understanding what the input and output files would look like, and if other people are having the same problem, that could be why you don’t have any answers yet.

Could you give us an example or two of (truncated) input files and what the corresponding output file would look like?