Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # Python script for removing EXOTIC tags in Dwarf Fortress RAW files
- #
- # Chee Sing Lee <cheesinglee@gmail.com>
- # 25 September 2011
- from os import walk
- from os import getcwd
- from os.path import join
- from fnmatch import fnmatch
- from shutil import copy2
- import io
- # recursively walk the directory tree, starting from current directory
- for (dirpath,dirnames,fnames) in walk( getcwd() ):
- for fname in fnames:
- if fnmatch(fname,'creature_*.txt'):
- filepath = join(dirpath,fname)
- # make a backup first
- copy2(filepath,filepath+'.bak')
- # read the file
- f = io.FileIO(filepath,'r+')
- f_string = f.read()
- f_string = f_string.replace('[PET_EXOTIC]','[PET]')
- f_string = f_string.replace('[MOUNT_EXOTIC]','[MOUNT]')
- # rewind so that we are overwriting
- f.seek(0)
- f.write(f_string)
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement