Batch Convert to Toon

There is an old 2006 script on the forums to batch convert all materials to toon setting with editable parameters.
I have not seen an updated version anywhere unfortunately. Does anyone have an ear to the ground on this topic for a python script to accomplish this?
I am not sure how many people use Blender and DAZ in conjunction but I do and love the toon with freestyle mix for graphic novel creation enjoyment :). I am just looking to increase work flow with a toon batch convert by not having to manually adjust every material and texture because that can take hours with large scenes.

Can you post the script?

If you don’t have it, I think it’s very easy to do, this code if for all materials, if you need only the materials in the selected objects let me know.


import bpy


#All materials. 


def setAllMaterialsToToon(intensity= 0.8,size=0.5,smooth=0.1):
    # no check for valid input 
    # Only changes materilas that are not type Toon.
    
    for mat in bpy.data.materials:
        if mat.diffuse_shader != 'TOON':
            mat.diffuse_shader = 'TOON'
            mat.diffuse_intensity = intensity
            mat.diffuse_toon_size = size
            mat.diffuse_toon_smooth = smooth
            
#Usage
setAllMaterialsToToon(intensity=1,size=1,smooth=1)

Thank you. That looks a bit nicer than what I came up with after a lot of trial and error attempting to learn python for this task.
Here was my attempt;

import the Blender module

import bpy

#Iterate over all members of the materials
for item in bpy.data.materials:
#Change diffuse shader to toon
item.diffuse_shader = ‘TOON’
#Set specular to zero
item.specular_intensity = (0.000)
#Set diffuse toon smooth
item.diffuse_toon_smooth = (0.100)
#Set diffuse toon size
item.diffuse_toon_size = (1.000)