| 
				
				westdale
								 
								 
									  
								
				 | 
			
				 
			Because one of my scripts has a lot of presets, I found it convenient to work in small batches in copies of the same filter and bring them together later. Merging a number of settings and then deleting a few was easier that copying individual ones!
 I found that writing down settings manually to apply them in another file was hard work, and I am lazy, so here is a small Python script that helped me. 
 It merges presets from one filter file into another -- it assumes, but does not check, that they are both the same type and have the same parameters to be set.
 I can't attach the file of this type so here goes, hoping that indents don't get destroyed  .....
 ===============================================================
 
 ## Merge of two Filter Forge files into a third
 ## it merges (only) the presets from the second file with all of the first file
 ## It sets the name of the new filter
 ## It demotes the DefaultPreset of the ins ert to a plain Preset
 
 import re  #regex
 
 ## --- se t up the data for the files to be processed  ----------------
 
 myFolder   = r'L:\GWshare\FilterForge\MyFiltersLDrive\Mergespace' 
 mainFile   = "Polar Twist code.ffxml"
 insertFile = "LookupGradients.ffxml"
 outputFile = "result.ffxml"
 scriptName = "Result"
 # if not testing, make the output file name the same as the script name to avoid confusion!
 ## ------------------------------------------------------------------
 
 fmain = open(myFolder+'\\'+mainFile) # open read text
 finsert = open(myFolder+'\\'+insertFile) # open read text
 fout = open(myFolder+'\\'+outputFile,'w') # open read text
 
 fm = fmain.readline()
 fi = finsert.readline()
 
 while fm.strip() != '</Presets>':  # write first file and its presets
    fout.write(fm)
    fm = fmain.readline()
 
 while fi.strip() != '<Presets>': # drop data before the presets from insert file
     fi = finsert.readline()
 fi = finsert.readline()
 
 while fi.strip() != '</Presets>' :  # write presets from insert file
    if 'DefaultPreset' in fi:
       fi = fi.replace('Default','')  # change default to normal preset
    fout.write(fi)
    fi = finsert.readline()
 fout.write('\t</Presets>\n')
 
 for line in fmain:    # write rest of main file
    if '<Information' in line :
       # replace name of filter with the supplied name
       line = re.sub('name-en="[^"]*"',   'name-en="' + scriptName + '"',   line)
    fout.write(line)
 
 fmain.close()
 finsert.close()
 fout.close()				 
			 |