Open main menu

UESPWiki β

UESPWiki:Oblivion Map Design/ConvertNames.py

< UESPWiki:Oblivion Map Design

This is a very rough Python script for renaming all the image files export from the Oblivion CS into a more usable format for the online map. Change the file paths used in the script to reflect where you are getting and storing the image files.

import os
import sys
import Image
import shutil

FileCount = 0
MinCellX = -64
MaxCellX = 69
MinCellY = -69
MaxCellY = 59
OutputXOffset = 64
OutputXFactor = 1
OutputYOffset = 59
OutputYFactor = -1
NoExistCount = 0
ZoomLevel = 16
NoExistFile = "water_low.jpg"

for CellX in range(MinCellX, MaxCellX + 1):
    for CellY in range(MinCellY, MaxCellY + 1):
        SrcFilename = 'f:\\obmaps\\resizejpgs\\tamriel.%(cellx)02d.%(celly)02d.jpg' % \
                   {'cellx': CellX, 'celly': CellY}
        OutX = CellX * OutputXFactor + OutputXOffset
        OutY = CellY * OutputYFactor + OutputYOffset
        OutputFilename = 'f:\\obmaps\\renamejpgs\\zoom%(zoom)d\\tamriel-%(outx)d-%(outy)d-%(zoom)d.jpg' % \
                   {'outx': OutX, 'outy': OutY, 'zoom': ZoomLevel}

        if not os.access(SrcFilename, os.F_OK):
            NoExistCount = NoExistCount + 1
            SrcFilename = 'f:\\obmaps\\resizejpgs\\water_low.jpg'
            #print NoExistCount, ') No Exist', SrcFilename

        print FileCount, ') ', SrcFilename, ' to ', OutputFilename
        shutil.copyfile(SrcFilename, OutputFilename)
        
        FileCount = FileCount + 1

print 'No Exist = ', NoExistCount
        
#FileCount = 100
#for file in os.listdir("f:\\obmaps\\resizejpgs\\"):
#    FileCount = FileCount + 1
#    print FileCount, file
#    if FileCount > 100:
#        break