I'm just starting out using args in BASH and am trying to script setting the 'Title' tag on a given .MKV to match its filename: less the extension. The command...
mkvpropedit "Good Life.mkv" --edit info --set "title=Good Life"
...works without issue and (thanks to another answered StackOverflow question), I can pull in the full filename - with spaces and extension - and reliably split it into the full filename (i.e. "Good Life.mkv") and the filename w/out extension: i.e. "Good Life". The full script (mkvRetitle.sh) is...
#!/bin/bash
echo "Change .MKV title to match its filename"
eval fileWhole=\${1}
eval fileTitle=$(echo "\${1%.*}")
# echo $fileWhole
# echo $fileTitle
mkvpropedit fileWhole --edit info --set "title=$fileTitle"
The actual calling of 'mkvpropedit' in my script, however, errors out. mkvpropedit returns Error: The file 'fileWhole' is not a Matroska file or it could not be found. I've tried ideas found in
Passing a string with spaces as a function argument in bash
but have had no luck and can find nothing else that looks likely: from other sites. I'd really appreciate the help. Thank you very much.
evalnonsense? (If another SO question's answer advised you to useeval, the quality of that answer is... suspect).evals (they're useless at best, dangerous at worst). Also,$(echo ...)is useless, since the$( )andechopretty much cancel each other out.echotakes a string and prints it as output, and$( )takes that output and turns it back into a string. Just use the string directly!