For others who end up here wrestling with shell scripts, arrays and spaces in filenames...... like my file list below;
$ ls *.meta
20160324 1850 - ABC - Clarke And Dawe.ts.meta
20160706 1515 - 9Gem - Agatha Christie's Poirot.ts.meta
20181213 0155 - 10 BOLD - Star Trek_ The Next Generation.ts.meta
20210424 1927 - ABCTV HD - The Durrells.ts.meta
20210501 1927 - ABCTV HD - The Durrells.ts.meta
20210818 1930 - SBS ONE HD - Tony Robinson's World By Rail.ts.meta
After a lot of searching and trying different approaches this worked out to be the least problematic and worked on MacOS 10.15
eval "list=( $(find . -name "*.ts" -exec echo \"{}\" \;) )"
for name in "${list[@]}"
do
res=`mediainfo --Output=''Video\;\%Width\%:%Height\%'' "$name"`
echo ${name} :: $res
sed -i .bak -e 5s/\;[[:digit:]]*:[[:digit:]]*// -e 5s/$/\;$res/ "$name.meta"
done
Ignoring the internals of what I was trying to achieve, the critical aspects were using eval and wrapping double quotes around the filename in the echo within the find. (What was I doing? I was pulling the resolution out of Enigma2 PVR recordings and writing it into line 5 of the related meta data file)
Thanks to all those who posted their own knowledge on the various issues that shell scripting generates.
echo $i
to see what it contains. – Bosomy