in reply to Get filename inside each file

If your data is in a simple and predictable format (i.e was generated) then a perl one-liner ought do the trick
perl -pi.bak -e '/from stuff/ or next; ($d)=$ARGV=~/(\d\d)\.txt$/; \ s/from stuff/$& where thing = "$d"/' *.txt
So that will replace every line containing the string 'from stuff' in every .txt file in the current directory with 'from stuff where thing = "$d"', where $d is the last two digits of the filename. See. perlrun for info on perl's command-line options, perlre for info on perl's regular expressions and perlvar for info on the $& variable.
HTH

_________
broquaint