Created
February 26, 2022 12:44
-
-
Save Xymph/8645abb39fce8b1fc5df9f6ed6ff2097 to your computer and use it in GitHub Desktop.
Omgifol (https://doomwiki.org/wiki/Omgifol) script to set a WAD's map slot from its filename
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# set WAD's map slot from filename, by Frans P. de Vries (Xymph) | |
import sys, re | |
from omg import * | |
if len(sys.argv) < 2: | |
print("\n Omgifol script: set slot from filename\n") | |
print(" Usage:") | |
print(" slotfile.py slot##.wad [-s oldslot]\n") | |
else: | |
# compile new slot & old pattern | |
newslot = sys.argv[1] | |
newslot = os.path.basename(newslot[:newslot.rfind('.')]).upper() | |
if "-s" in sys.argv: | |
oldslot = sys.argv[-1] | |
else: | |
oldslot = re.sub(r'\d+$', '', newslot) + '*' | |
# load WAD & rename slot | |
print("Loading %s..." % sys.argv[1]) | |
wadio = WadIO(sys.argv[1]) | |
entry = wadio.find(oldslot) | |
if entry is not None: | |
wadio.rename(entry, newslot) | |
print("Writing %s..." % sys.argv[1]) | |
wadio.save() | |
else: | |
print("Not found: %s" % oldslot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment