Smart rule that removes underscore in filenames

I’m curious: what RegEx did you try?

PS: This is rather simply done with pure AppleScript.

property illegalCharacters : {":", "/", "\\"}

on performSmartRule(theRecords)
	set removeCharacter to "_" -- What character do you want to remove?
	set replaceWith to " " -- What character do you want to replace it with?
	set od to AppleScript's text item delimiters -- Cache the default text item delimiters
	
	tell application id "DNtp"
		if replaceWith is in illegalCharacters then log message replaceWith info "This is an illegal character and can't be used in filenames."
		repeat with theRecord in theRecords
			set recordName to (name of theRecord)
			if (recordName contains removeCharacter) then -- Does the file need to be acted on?				
				set AppleScript's text item delimiters to removeCharacter -- If so, delimit with the character to remove
				set nameComponents to (text items of recordName) -- Get a list of the parts of the name that were separated, i.e., delimited by the specified character
				set AppleScript's text item delimiters to replaceWith -- Set the delimiter to the replacement character
				set adjustedName to (nameComponents as string) -- Coerce the list of name components back into a string, joining the parts with the current delimiter.
				set name of theRecord to adjustedName -- Rename the file
			end if
		end repeat -- And move on…
		set AppleScript's text item delimiters to od -- At the end, make sure to reset the text item delimiters
	end tell
end performSmartRule