M HYPE SPLASH
// updates

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%.*}")
done

How do I edit this to get only the name upto xxxyyy?

3

1 Answer

You can use:

"${video%s.*}"

This will delete everything from (and including) the last s. until the end of the string.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy