Automator: How to replace a particular string with the filename?
You can use a Run Shell Script action, with a script like this:

basename=${1##*/}
tmp=`mktemp -t $$`
sed -e "s/STRING_TO_BE_REPLACED/$basename/g" "$1" &gt; $tmp &amp;&amp; mv $tmp "$1"


with Pass input: set to as arguments: