You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
| import os
 | |
| 
 | |
| ASEPRITE_PATH = "D:/Steam/steamapps/common/Aseprite/aseprite.exe"
 | |
| 
 | |
| FILE_NAME_FLAG = "[FILE_NAME]"
 | |
| LAYER_NAME_FLAG = "[LAYER_NAME]"
 | |
| OUTPUT_NAME_FLAG = "[OUTPUT_NAME]"
 | |
| CMD_QUERY_LAYAERS = ASEPRITE_PATH + \
 | |
|     " -b --list-layers --all-layers " + FILE_NAME_FLAG
 | |
| CMD_EXPORT = ASEPRITE_PATH + " -b --layer " + LAYER_NAME_FLAG + \
 | |
|     " " + FILE_NAME_FLAG + " --save-as "+OUTPUT_NAME_FLAG+".png"
 | |
| 
 | |
| 
 | |
| def func(path):
 | |
|     filelist = os.listdir(path)
 | |
|     os.chdir(path)
 | |
|     for filename in filelist:
 | |
|         filepath = os.path.join(path, filename)
 | |
|         if os.path.isdir(filepath):
 | |
|             print("--", filepath)
 | |
|             func(filepath)
 | |
|         else:
 | |
|             if filename.endswith(".aseprite"):
 | |
|                 print("["+filename+"]")
 | |
|                 cmdtag = CMD_QUERY_LAYAERS.replace(FILE_NAME_FLAG, filename)
 | |
|                 f = os.popen(cmdtag, "r")
 | |
|                 for tagLine in f.readlines():
 | |
|                     layer = tagLine.replace("\n", "")
 | |
|                     outputName = filename.split(".")[0]+"_"+layer
 | |
|                     print(outputName)
 | |
|                     cmdexport = CMD_EXPORT.replace(
 | |
|                         FILE_NAME_FLAG, filename).replace(LAYER_NAME_FLAG, layer).replace(OUTPUT_NAME_FLAG, outputName)
 | |
|                     print(cmdexport)
 | |
|                     os.popen(cmdexport, "r")
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     func(os.getcwd())
 |