1:26 PM
A: How to include directories and subdirectories in a batch file

glenn jackmanWith bash, you'd set the globstar and nullglob shell options and use ** to recurse into subdirectories: shopt -s globstar nullglob for mkvfile in **/*.mkv; do mkvpropedit "$mkvfile" -e info -s title="${mkvfile::-4}" done See 4.3.2 The Shopt Builtin in the manual. Note you can also use ${m...

Getting error shopt: not found, Bad substitution
Are you using /bin/bash or /bin/sh ? shopt is bash-specific.
/bin/bash - same as the code sample I provided.
find . -name '*.mkv' -exec sh -c 'mkvpropedit "$1" -e info -s title="${1%.mkv}"' sh {} \; Works like a charm but it puts the directory path in the metadata name also.
Silly me I had a typo in the new script. Apologies, your script works perfectly. No error after the correction. ;)
Any suggestion to preventing the directory tree being included in the meta data information?
Answer updated to remove the directory from the title string.
getting closer, what that change did was took the ./ from the beginning of the file name but left the rest of the directory name in the title string. So from " ./instruction/class1/innovation.mkv " to " instruction/class1/innovation.mkv "
1:26 PM
Really? What does this output for you: sh -c 'echo title="$(basename "${1%.mkv}")"' - "./foo/bar/baz.mkv" ? And if the result is not title=baz, then what is your OS (and version) and what is /bin/sh on your system?
Nothing just goes to >
Distributor ID: Ubuntu Description: Ubuntu 16.04.4 LTS Release: 16.04 Codename: xenial GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
echo $SHELL /bin/bash
Trying to change shells to /bin/sh no command is letting it change its stuck in bash. I cant seem to get the version of /bin/sh but cat is telling me its installed.
ls -l /bin/sh would be informative.
The output of that command is - lrwxrwxrwx 1 root root 4 Feb 17 2016 /bin/sh -> dash
Tried the script on two other completely different builds and versions of ubuntu with the same result.