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 7628373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:35:09+00:00 2026-05-31T05:35:09+00:00

I use DJing software on linux (xwax) which uses a ‘scanning’ script ( visible

  • 0

I use DJing software on linux (xwax) which uses a ‘scanning’ script (visible here) that compiles all the music files available to the software and outputs a string which contains a path to the filename and then the title of the mp3. For example, if it scans path-to-mp3/Artist – Test.mp3, it will spit out a string like so:

path-to-mp3/Artist - Test.mp3[tab]Artist - Test

I have tagged all my mp3s with BPM information via the id3v2 tool and have a commandline method for extracting that information as follows:

id3v2 -l name-of-mp3.mp3 | grep TBPM | cut -D: -f2

That spits out JUST the numerical BPM to me. What I’d like to do is prepend the BPM number from the above command as part of the xwax scanning script, but I’m not sure how to insert that command in the midst of the script. What I’d want it to generate is:

path-to-mp3/Artist - Test.mp3[tab][bpm]Artist - Test

Any ideas?

  • 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-05-31T05:35:10+00:00Added an answer on May 31, 2026 at 5:35 am

    It’s not clear to me where in that script you want to insert the BPM number, but the idea is this:

    • To embed the output of one command into the arguments of another, you can use the “command substitution” notation `...` or $(...). For example, this:

      rm $(echo abcd)
      

      runs the command echo abcd and substitutes its output (abcd) into the overall command; so that’s equivalent to just rm abcd. It will remove the file named abcd.

    • The above doesn’t work inside single-quotes. If you want, you can just put it outside quotes, as I did in the above example; but it’s generally safer to put it inside double-quotes (so as to prevent some unwanted postprocessing). Either of these:

      rm "$(echo abcd)"
      rm "a$(echo bc)d"
      

      will remove the file named abcd.

    • In your case, you need to embed the command substitution into the middle of an argument that’s mostly single-quoted. You can do that by simply putting the single-quoted strings and double-quoted strings right next to each other with no space in between, so that Bash will combine them into a single argument. (This also works with unquoted strings.) For example, either of these:

      rm a"$(echo bc)"d
      rm 'a'"$(echo bc)"'d'
      

      will remove the file named abcd.


    Edited to add: O.K., I think I understand what you’re trying to do. You have a command that either (1) outputs out all the files in a specified directory (and any subdirectories and so on), one per line, or (2) outputs the contents of a file, where the contents of that file is a list of files, one per line. So in either case, it’s outputting a list of files, one per line. And you’re piping that list into this command:

    sed -n '
    {
    # /[<num>[.]] <artist> - <title>.ext
    s:/\([0-9]\+.\? \+\)\?\([^/]*\) \+- \+\([^/]*\)\.[A-Z0-9]*$:\0\t\2\t\3:pi
    t
    
    # /<artist> - <album>[/(Disc|Side) <name>]/[<ABnum>[.]] <title>.ext
    s:/\([^/]*\) \+- \+\([^/]*\)\(/\(disc\|side\) [0-9A-Z][^/]*\)\?/\([A-H]\?[A0-9]\?[0-9].\? \+\)\?\([^/]*\)\.[A-Z0-9]*$:\0\t\1\t\6:pi
    t
    
    # /[<ABnum>[.]] <name>.ext
    s:/\([A-H]\?[A0-9]\?[0-9].\? \+\)\?\([^/]*\)\.[A-Z0-9]*$:\0\t\t\2:pi
    }
    '
    

    which runs a sed script over that list. What you want is for all of the replacement-strings to change from \0\t... to \0\tBPM\t..., where BPM is the BPM number computed from your command. Right? And you need to compute that BPM number separately for each file, so instead of relying on seds implicit line-by-line looping, you need to handle the looping yourself, and process one line at a time. Right?

    So, you should change the above command to this:

    while read -r LINE ; do # loop over the lines, saving each one as "$LINE"
        BPM=$(id3v2 -l "$LINE" | grep TBPM | cut -D: -f2) # save BPM as "$BPM"
        sed -n '
        {
        # /[<num>[.]] <artist> - <title>.ext
        s:/\([0-9]\+.\? \+\)\?\([^/]*\) \+- \+\([^/]*\)\.[A-Z0-9]*$:\0\t'"$BPM"'\t\2\t\3:pi
        t
    
        # /<artist> - <album>[/(Disc|Side) <name>]/[<ABnum>[.]] <title>.ext
        s:/\([^/]*\) \+- \+\([^/]*\)\(/\(disc\|side\) [0-9A-Z][^/]*\)\?/\([A-H]\?[A0-9]\?[0-9].\? \+\)\?\([^/]*\)\.[A-Z0-9]*$:\0\t'"$BPM"'\t\1\t\6:pi
        t
    
        # /[<ABnum>[.]] <name>.ext
        s:/\([A-H]\?[A0-9]\?[0-9].\? \+\)\?\([^/]*\)\.[A-Z0-9]*$:\0\t'"$BPM"'\t\t\2:pi
        }
        ' <<<"$LINE" # take $LINE as input, rather than reading more lines
    done
    

    (where the only change to the sed script itself was to insert '"$BPM"'\t in a few places to switch from single-quoting to double-quoting, then insert the BPM, then switch back to single-quoting and add a tab).

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

Sidebar

Related Questions

Suppose I have a server that runs on Linux on which I would like
We have 3 software products which use the same .net dlls(code + legacy). All
I currently use Ant to build Java software. However, all development that I have
I'm doing background research for a project to write a software tool that converts
In my software, I use libxml2 and xmlsec to manipulate (obviously) XML data structures.
What term should I use to describe situations (or bugs in software) caused by
I'm calculating fixedpoint reciprocals in Q22.10 with Goldschmidt division for use in my software
I am developing a library that uses one or more helper executable in the
I am in the process of writing a Ruby script/app that helps me compiling
I want to use a tool ( ffmpeg ) that is under GNU Lesser

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.