Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:05:52+00:00 2026-06-12T17:05:52+00:00

I am writing a script which you can pass a file name into as

  • 0

I am writing a script which you can pass a file name into as an argument and it’ll only run if it’s a certain file extension.

flac2mp3 "01 Song.flac"

or

flac2mp3 "01 Song.FLAC"

I know there a lot of scripts out there showing you how to convert flac to mp3, but this is my script and I want to learn how to write the script using this method.

It’s so I can learn arguments and for when I feel like converting only 1 individual file. (for multiple files I just wrote a for loop with *.flac inside the script)

I just want to learn how to check if the $1 argument contains *.[Ff][Ll][Aa][Cc]

Here’s what I cobbled up together from the internet so far (which I know is embarrassingly wrong but I wanted to show what I was going for) :

#!/bin/bash
#flac2mp3

if [ -z $1 ] && [[$1 !=~ *.[Ff][Ll][Aa][Cc]]];then echo "Give FLAC File Name"; exit 0;fi

OUTF=${1%.flac}.mp3

ARTIST=$(metaflac "$1" --show-tag=ARTIST | sed s/.*=//g)
TITLE=$(metaflac "$1" --show-tag=TITLE | sed s/.*=//g)
ALBUM=$(metaflac "$1" --show-tag=ALBUM | sed s/.*=//g)
GENRE=$(metaflac "$1" --show-tag=GENRE | sed s/.*=//g)
TRACKNUMBER=$(metaflac "$1" --show-tag=TRACKNUMBER | sed s/.*=//g)
DATE=$(metaflac "$1" --show-tag=DATE | sed s/.*=//g)

flac -c -d "$1" | lame -m j -q 0 --vbr-new -V 0 -s 44.1 - "$OUTF"
id3 -t "$TITLE" -T "${TRACKNUMBER:-0}" -a "$ARTIST" -A "$ALBUM" -y "$DATE" -g "${GENRE:-12}" "$OUTF"

done

Please and Thank Your for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:05:54+00:00Added an answer on June 12, 2026 at 5:05 pm

    Try the following code:

    shopt -s nocasematch
    
    if [[ $1 == *flac ]]; then
        echo "ok"
    fi
    

    This is case insensitive.

    EDIT

    $ LANG=C help shopt
    shopt: shopt [-pqsu] [-o] [optname ...]
        Set and unset shell options.
    
        Change the setting of each shell option OPTNAME.  Without any option
        arguments, list all shell options with an indication of whether or not each
        is set.
    
        Options:
          -o        restrict OPTNAMEs to those defined for use with `set -o'
          -p        print each shell option with an indication of its status
          -q        suppress output
          -s        enable (set) each OPTNAME
          -u        disable (unset) each OPTNAME
    
        Exit Status:
        Returns success if OPTNAME is enabled; fails if an invalid option is
        given or OPTNAME is disabled.
    

    If you run shopt alone in a shell, you will see al options available :

    $ shopt
    autocd          on
    cdable_vars     on
    cdspell         off
    checkhash       off
    checkjobs       off
    checkwinsize    off
    cmdhist         on
    compat31        off
    compat32        off
    compat40        off
    compat41        off
    direxpand       off
    dirspell        off
    dotglob         on
    execfail        off
    expand_aliases  on
    extdebug        off
    extglob         on
    extquote        on
    failglob        off
    force_fignore   on
    globstar        on
    gnu_errfmt      off
    histappend      on
    histreedit      off
    histverify      off
    hostcomplete    off
    huponexit       off
    interactive_comments    on
    lastpipe        off
    lithist         off
    login_shell     off
    mailwarn        off
    no_empty_cmd_completion off
    nocaseglob      off
    nocasematch     off
    nullglob        off
    progcomp        on
    promptvars      on
    restricted_shell        off
    shift_verbose   off
    sourcepath      on
    xpg_echo        off
    

    To know what does all these options :

    man bash | less +/'^SHELL BUILTIN COMMANDS'
    

    then search `shopt from within this section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Groovy script which uses third party java code that I can't
I'm writing a PHP script which uses serialized arrays to store data. How can
I am writing a php script which will run through cron . Its task
I need help in writing a C# script which can access a secured shared
I'm interested in writing a short python script which uploads a short binary file
I have a question about writing a script which can manage to play online
I'w writing a PHP script that uses Montage, which is an extension of ImageMagick
I'm writing a bash script which has to pass a variable to another program:
I am currently writing a script which parses the ServiceTage, Computername and Username from
I am writing a script which counts all files and folders recursively. I tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.