You can upgrade as many walls as your storages can allow if they were completely filled to the rim, and this does not depend on the number of wall units (like I previously thought). Here are a few examples:
Say you have 2 lv 6 gold storages which gives you 101,000 max gold that you can have that is ready to be used (the extra 1,000 comes from the Town Hall). With that, you can technically upgrade 101 lv 2 walls to lv 3 (it costs 1,000 gold to upgrade 1 lv 2 wall to lv 3).
With those same storages, you can upgrade at most 20 lv 3 walls to lv 4 and at most 10 lv 4 walls to lv 5.
The reason why I mentioned at most 10 walls earlier was because I currently have lv 6 walls and 2 lv 10 gold storages, which means I have a max of 2,001,000 gold with the upgrade cost of walls being 200,000 gold per unit. 10 times that gives 2 million.
Also, it doesn't matter whether all the walls are of the same level. The game will automatically recalculate the required resources for the upgrade of each piece of wall.
So if you have for example 9 lv 1 walls and 1 lv 2 wall on a row and upgrade all of them, you will require 200*9 = 1800 gold + 1000 gold for a total of 2800 gold and you will get 9 lv 2 walls and 1 lv 3 wall.
If you have a wall you cannot upgrade further, the cost will not be included so that only the ones you can upgrade will be upgraded provided you have the required resources.