Apply a color scheme throughout a directory

The following script, inspired by a question from parakeet (Applying label and background colors to folder system?), applies a color scheme throughout a folder/directory.

Posted here in case it might be of general interest.

to chooseLabel for s
	tell application "Finder" to set i to label index of s's item 1
	set l to {"None", "Orange", "Red", "Yellow", "Blue", "Purple", "Green", "Gray"}
	tell (choose from list l with prompt "Please choose a label color:" default items l's item (i + 1))
		if it is false then error number -128
		tell item 1 to repeat with i from 1 to count l
			if it is l's item i then return i - 1
		end repeat
	end tell
end chooseLabel

to chooseBackground for s
	tell application "Finder" to repeat with i in s
		if i's class is folder then
			set c to background color of icon view options of i's window
			if c is {0, 0, 0} then return choose color default color {65535, 65535, 65535} (* bug workaround *)
			return choose color default color c
		end if
	end repeat
	{65535, 65535, 65535}
end chooseBackground

to changeColors at s to l against b
	tell application "Finder" to repeat with i in s
		set i's label index to l
		if i's class is folder then
			set background color of icon view options of i's window to b
			my (changeColors at (i's items) to l against b)
		end if
	end repeat
end changeColors

tell application "Finder" to set s to selection
if (count s) > 0 then changeColors at s to (chooseLabel for s) against (chooseBackground for s)

Here’s a related script that only changes folders:

property myBackgroundColor : {65535, 52428, 0}
property myIconSize : 128

on run
	choose folder with multiple selections allowed
	open result
end run

on open theseItems
	try
		tell application "Finder"
			repeat with thisItem in theseItems
				set background color of icon view options of thisItem's window to myBackgroundColor
				set icon size of icon view options of thisItem's window to myIconSize
				
				get (every folder of entire contents of thisItem) as alias list
				repeat with thisSubFolder in result
					set background color of icon view options of thisSubFolder's window to myBackgroundColor
					set icon size of icon view options of thisSubFolder's window to myIconSize
				end repeat
			end repeat
		end tell
	on error errorMsg number errorNum
		display alert "Error " & errorNum message errorMsg buttons "Cancel" default button 1
	end try
end open