How to get part of the filename using (basename "${video%.*}") in bash script?
By Emma Terry •
I have a set of videos scalled xxxyyys.mp4, each filename ends with s. I want to execute a script that takes only the name upto xxxyyy for the argument basefile.
So far, what I have is
for video in folder/*
do python script.py -i "${video%*.mp4}" --basefile $(basename "${video%.*}")
doneHow do I edit this to get only the name upto xxxyyy?
31 Answer
You can use:
"${video%s.*}"This will delete everything from (and including) the last s. until the end of the string.