Created
July 13, 2012 19:46
-
-
Save Shaptic/3106976 to your computer and use it in GitHub Desktop.
Find all map tile files
This file contains hidden or 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
import os | |
# Finds all image files starting with | |
# Map_ and ending with the .png extension. | |
# Returns a list of all images. | |
def find_tiles(directory): | |
textures = [] | |
for root, dirs, files in os.walk(directory): | |
for tmp_file in files: | |
if(tmp_file.startswith("Map_") and tmp_file.endswith(".png")): | |
textures.append(tmp_file) | |
print "Found %s in %s" % (tmp_file, root) | |
return textures | |
def main(): | |
textures = find_tiles("Data/Images") | |
print "%d textures found!" %(len(textures)) | |
if(len(textures) > 0): | |
texture_file = open("Data/Levels/ValidNames.dat", "w") | |
texture_file.write("// This list has been automatically generated by a script.\n") | |
for texture in textures: | |
texture_file.write("Data/Images/Map/%s\n" % (texture)) | |
texture_file.close() | |
if(__name__ == "__main__"): | |
main() | |
raw_input("Press ENTER to exit.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment