I am currently working on a script, that shall set the titles of all found MKV/MKA/MKS files to their basename for example:
/path/to/the/file/this is a cool title.mkv
Should be automatically edited with mkvpropedit and the title shall be set to "this is a cool title".
I can ATM set the title to a static value, but as the title should always be the filename (without extension) it somehow does not work.
My script is as following:
find . -iname "*.mk*" -type f -exec mkvpropedit -e info --set title="$(basename)" {} \;
It runs "find", then -exec on every found entry and set the title to the found entrys "basename". At least thats how it should work. But basename does not work since it does not know what it should create a basename from.
Is there a way to pass the path to a subcommand in a -exec command?
CodePudding user response:
You can do this sort of thing by passing the filename to sh:
find . -iname "*.mk*" -type f -exec sh -c 'mkvpropedit -e info --set title="$(basename "$1")" "$1"' _ {} \;