Help with migrating from DotNetNuke to WordPress

I am currently in the process of migrating a blog that is based on IIS8 and DotNetNuke. As things are right now the URLs for images contain spaces in them.

An example URL would be http://oldsite.com/Portals/0/post%20image%20650%20web.jpg

What I want is for the new site URL for images to be http://newsite.com/media/post-image-650-20web.jpg

Can someone here help me with the regex and rewrite tools necessary for this? From my research the closest result i found is converting “_” to “-” using the code below.

location ~ _ {
  rewrite ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5-$6-$7-$8-$9;
  rewrite ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5;
  rewrite ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3;
  rewrite ^([^_]*)_(.*)$ $1-$2;
  rewrite ^ $uri permanent;
}