I try to find files in a directory that have mp4 mkv extensions only. But I also want that these finded files same name, but different extensions. For example: video.mp4 video.mkv . I tried to restrict extensions that I wanted like below, but I couldn't do the rest:

for i in *
        case "${i##*.}" in
  • 1
    Find in what? what is your OS? are you trying to write a code or direct shell commands?
    – Eng7
    Commented Feb 12, 2020 at 12:58
  • I use Linux Mint. I try to write a shell script with sh, no bash.
    – user386273
    Commented Feb 12, 2020 at 13:03
  • Could you please clarify what you are trying to achieve? What is FFmpegForCompressAutomaticJob ? You don't seem to be passing "$i" as an argument... Do you want to run that for every .mp4, .mP4, .Mkv, etc. Or only run it for a file if it's corresponding .??? doesn't already exist? – Are you trying to make your script portable or could you use bash/etc. –specific features?
    – user391836
    Commented Feb 12, 2020 at 13:54

1 Answer 1


You can create a function instead ( or a script if you like ).

processor() {
  for f; do
    [ -f "$f" ] || continue
    case $f in
        echo "converting $f"
        : Do something here ;;
        echo "converting $f"
        : Do another thing here ;;
        echo "Found $f" ;;

Now try it in a directory

processor *

You must log in to answer this question.