I made this to copy the files to the old format, and WorldViewer (and old version satelite map maker too) worked fine for me. Your results may vary.
I've been fighting months with Carpal Tunnel Syndrome (surgery suggested) in both wrists, so the script below is sloppy and unpolished. It works for me. It is a
script to copy a new format region legends/maps to a new directory in old format. Yes, I know I could have made it shorter/efficient; I worked on it off and on (using copy/paste, replace, etc for repeating parts). Normally I would have made something more efficient, user friendly, error-proof, and documented. Im embarrassed to release it, but maybe someone can use it (or better, improve it).
" to be your path to your file. It SHOULD work on linux and mac, since I think I used cross platform functions. I release the hideous monster...
# /usr/bin/python
#
# exports_new2old.py
#
# Author: "MrPalmer"
# Version: 0.1-alpha
import re
import shutil
import os, errno
from os import listdir as ldir
from os.path import isfile, join
# Old format
#
# world_graphic-bm-region1-126--10081.png
# world_map-region1-126--10081.png
# region1-world_gen_param.txt
#
# ^(world_graphic)\-(bm|detailed|drn|el|elw|evil|hyd|rain|sal|sav|str|tmp|trd|veg|vol)\-([^\-]+)\-(\d+\-+\d+)\.(bmp|jpg|png)$
# ^(world_map)\-([^\-]+)\-(\d+)\-+(\d+)$
# ^([^\-]+)\-(world_(?:history|sites_and_pops))\.(txt)$
# ^([^\-]+)\-(legends)\.(xml)$
# ^([^\-]+)\-(world_gen_param)\.(txt)$
# ^([^\-]+)\-(legends_plus)\.(xml)$
#
# New format
#
# region3-00050-01-01-veg.bmp
#
# ^([^\-]+)\-(\d+\-\d+\-\d+)\-(bm|detailed|drn|el|elw|evil|hyd|rain|sal|sav|str|tmp|trd|veg|vol)\.(bmp|jpg|png)$
# ^([^\-]+)\-(\d+\-\d+\-\d+)\-(world_map)\.(bmp|jpg|png)$
# ^([^\-]+)\-(\d+\-\d+\-\d+)\-(world_(?:history|sites_and_pops))\.(txt)$
# ^([^\-]+)\-(\d+\-\d+\-\d+)\-(legends)\.(xml)$
# ^([^\-]+)\-(world_gen_param)\.(txt)$
# ^([^\-]+)\-(legends_plus)\.(xml)$
#
### CHANGE THIS TO YOUR PATH ###
mypath=r"D:\DF\Dwarf Fortress 40_10 Starter Pack r1\Dwarf Fortress 0.40.10"
###############################
re_old_wgraph = re.compile(r"^(world_graphic)\-(?P<fname>bm|detailed|drn|el|elw|evil|hyd|rain|sal|sav|str|tmp|trd|veg|vol)\-(?P<region>[^\-]+)\-(?P<year>\d+)\-+(?P<xnum>\d+)\.(?P<ext>bmp|jpg|png)$",re.I)
re_old_wmap = re.compile(r"^(?P<fname>world_map)\-(?P<region>[^\-]+)\-(?P<year>\d+)\-+(?P<xnum>\d+)\.(?P<ext>bmp|jpg|png)$",re.I)
re_old_whist = re.compile(r"^(?P<region>[^\-]+)\-(?P<fname>world_(?:history|sites_and_pops))\.(?P<ext>txt)$",re.I)
re_old_legend = re.compile(r"^(?P<region>[^\-]+)\-(?P<fname>legends)\.(?P<ext>xml)$",re.I)
re_old_wparam = re.compile(r"^(?P<region>[^\-]+)\-(?P<fname>world_gen_param)\.(?P<ext>txt)$",re.I)
re_old_legend2 = re.compile(r"^(?P<region>[^\-]+)\-(?P<fname>legends_plus)\.(?P<ext>xml)$",re.I)
re_new_wgraph = re.compile(r"^(?P<region>[^\-]+)\-(?P<year>\d+)\-(?P<xnum>\d+\-\d+)\-(?P<fname>bm|detailed|drn|el|elw|evil|hyd|rain|sal|sav|str|tmp|trd|veg|vol)\.(?P<ext>bmp|jpg|png)$",re.I)
re_new_wmap = re.compile(r"^(?P<region>[^\-]+)\-(?P<year>\d+)\-(?P<xnum>\d+\-\d+)\-(?P<fname>world_map)\.(?P<ext>bmp|jpg|png)$",re.I)
re_new_whist = re.compile(r"^(?P<region>[^\-]+)\-(?P<year>\d+)\-(?P<xnum>\d+\-\d+)\-(?P<fname>world_(?:history|sites_and_pops))\.(?P<ext>txt)$",re.I)
re_new_legend = re.compile(r"^(?P<region>[^\-]+)\-(?P<year>\d+)\-(?P<xnum>\d+\-\d+)\-(?P<fname>legends)\.(?P<ext>xml)$",re.I)
re_new_wparam = re.compile(r"^(?P<region>[^\-]+)\-(?P<fname>world_gen_param)\.(?P<ext>txt)$",re.I)
re_new_legend2 = re.compile(r"^(?P<region>[^\-]+)\-(?P<fname>legends_plus)\.(?P<ext>xml)$",re.I)
def dictdefs(dict,defs):
for k in defs.keys():
if not k in dict:
dict[k] = defs[k]
def fadd(o,fn,pth,im): #rg,yr=-999,xnum=-999,fname="?",ex="?"):
m=im.groupdict()
dictdefs(m,{'year': -999,'xnum': -999,'fname': "?",'ext': "?"})
okey=m['region']
fname=m['fname']
#if fname == "?":
# return False
td = dict()
if m['year'] > -999:
td["year"] = m['year']
okey = okey + "-" + m['year']
if m['xnum'] > -999:
td["xnum"] = m['xnum']
okey = okey + "-" + m['xnum']
okey = okey + "-" + m['fname']
td["fname"] = m['fname']
td["region"] = m['region']
td["ext"] = m['ext']
td["file"] = fn
td["path"] = pth
if not m['region'] in o['regionlist']:
o['regionlist'].append(m['region'])
if m['year'] > -999:
ry = m['region'] + "-" + m['year']
if m['xnum'] > -999:
ry = ry + '-' + m['xnum']
if not ry in o['regionyears']:
o['regionyears'].append(ry)
o[okey] = td
return True
def scanfiles(mypath,oldf,newf):
for f in ldir(mypath):
if isfile(join(mypath,f)):
m = re_new_wgraph.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_new_wmap.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_new_whist.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_new_legend.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_new_wparam.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_new_legend2.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_old_wgraph.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_old_wmap.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_old_whist.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_old_legend.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_old_wparam.match(f)
if m:
fadd(newf,f,mypath,m)
m = re_old_legend2.match(f)
if m:
fadd(newf,f,mypath,m)
return True
def debug1(oldf,newf):
print "\nOld Regions\n-----------"
for n in oldf['regionlist']:
print n
print "\nOld Region Years\n----------------"
for n in oldf['regionyears']:
print n
print "\nNew Regions\n-----------"
for n in newf['regionlist']:
print n
print "\nNew Region Years\n----------------"
for n in newf['regionyears']:
print n
print "\nOther Old\n--------------"
for n in (oldf.keys()):
if n not in ['regionlist','regionyears']:
print n
print "\nOther New\n--------------"
for n in sorted(newf.keys()):
if n not in ['regionlist','regionyears']:
print n
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise
### Optional newpath is where to store files
def normregs2old(mypath,oldf,newf,newpath=None):
if newpath is None:
newpath = join(mypath,'regions2old')
for k in newf:
newname = None
if k not in ['regionlist','regionyears']:
wegood = True
dd = newf[k]
dictdefs(dd,{'year': 0,'xnum': 0,'fname': "ERROR",'ext': "ERR"})
x = int(str(dd['xnum']).replace('-',''))
if newf[k]['fname'] in ['bm','detailed','drn','el','elw','evil','hyd','rain','sal','sav','str','tmp','trd','veg','vol']:
# world_graphic-bm-region1-126--10081.png
newname = "world_graphic-{0}-{1}-{2}--{3:05d}.{4}".format(dd['fname'], dd['region'], dd['year'], x, dd['ext'])
elif newf[k]['fname'] in ['world_map']:
newname = "{0}-{1}-{2}--{3:05d}.{4}".format(dd['fname'], dd['region'], dd['year'], x, dd['ext'])
elif newf[k]['fname'] in ['world_history','world_sites_and_pops','world_gen_param','legends','legends_plus']:
newname = "{1}-{0}.{4}".format(dd['fname'], dd['region'], dd['year'], x, dd['ext'])
else:
print("ERROR: Confused with {0}".format(dd['file']))
wegood = False
if wegood:
mkdir_p(join(newpath,"{0}-{1}-{2}".format(dd['region'],dd['year'],dd['xnum'])))
#print (dd['file']+' => '+newname)
shutil.copyfile(os.path.normpath(join(mypath,dd['file'])),os.path.normpath(join(newpath,join("{0}-{1}-{2}".format(dd['region'],dd['year'],dd['xnum']),newname))))
return True
newf = dict()
newf['regionlist'] = list()
newf['regionyears'] = list()
oldf = dict()
oldf['regionlist'] = list()
oldf['regionyears'] = list()
scanfiles(mypath,oldf,newf)
normregs2old(mypath,oldf,newf)
#debug1(oldf,newf)