May i recommend using the iptables-save file rather than the output of iptables -nvL. Since the iptables-save file is the same format as iptables commands, which will be a lot easier than having to parse the output from -nvL.
If you want somebody to write your script for you, that aint gunna happen. We're aren't a do it for you type of forum, we're here to help you learn how to do it yourself.
Personally, i would do this in a bash script, run iptables-save, grep to put the rules into variables, and then sed to replace whatever is on line number $x with the contents of the variables, then reload iptables.
This will assume that you are swapping LINE numbers, not RULE numbers inside the chain, to do this with rule numbers, you would grep for the relevant chain (probably also passed as a parameter to the script), and also keep track of the line number since this wont match the line numbers you are using with sed.