The scripts do seem to work for me with a few test files. You could add "set -x" to the top of the script and it will output all the commands being executed. That might give you an idea what is going wrong.
processtxt.sh
----
#!/usr/bin/env bash
set -x
directory="$1/*.txt"
for f in $directory
do
echo "Processing $f..."
fullfile="$f"
filename=$(basename "$fullfile")
filename_woext="${filename%.*}"
sed -i '' "s/#BASENAME#/$filename_woext/g" $fullfile
done
----
% ./processtxt.sh files
+ directory='files/*.txt'
+ for f in '$directory'
+ echo 'Processing files/testing1.txt...'
Processing files/testing1.txt...
+ fullfile=files/testing1.txt
++ basename files/testing1.txt
+ filename=testing1.txt
+ filename_woext=testing1
+ sed -i '' s/#BASENAME#/testing1/g files/testing1.txt
[fletcher]
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or believe that the application isn't working correctly, please email "
sup...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: <
https://mastodon.social/@bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
bbedit+un...@googlegroups.com.
> To view this discussion visit
https://groups.google.com/d/msgid/bbedit/CD71B3FF-B1C9-4BEB-9CE8-82053C11265A%40gmail.com.