How to get filename without the extension in Fish script?Linux Mac OS X UNIX Fish Tips & Tricks
We can use string split like this
(string split -r -m1 . $filename).
I use this method in my Fish script function.
function vidfps --description "vidfps <input.mp4>" ffmpeg -i $argv -filter:v fps=fps=24 (string split -r -m1 . $argv)-24fps.mp4 end
The above function is located in my
~/.config/fish/config.fish file. So I can use it to convert a video to a 24 frames-per-second video using ffmpeg. the code
(string split -r -m1 . $argv) give me the filename without extension. But if I want to get the extension itself, I can use this code
(string split -r -m1 . $argv).
If the path has folders or directories and you want to strip them out, to get only the file name, use this code
(basename $filename | string split -r -m1 .).
I hope this helps you. You know someone will benefit from this, share it with him/her, a friend or colleage.