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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:38:57+00:00 2026-05-26T15:38:57+00:00

I have been using mp3info to calculate my file length using the following syntax:

  • 0

I have been using mp3info to calculate my file length using the following syntax:

 mp3info -p "%S" /path/to/file

whenever I use the code with the filename I get the correct output:

 mp3info -p "%S" far_from_love.mp3

However, on storing the filename in a string variable and then using the variable I get an error:

 SyntaxError: invalid syntax

Could anyone tell me how to correctly use the command with a variable filename?

this is the python code which uses mp3info

listing=os.listdir("C:\\Python27")
for f in listing:
    if fnmatch.fnmatch(f,'*.mp3'):

         ext=f[:-4]                             #extract name of file without extension
         WAVE_OUTPUT_FILENAME="%s.wav"%ext
         print WAVE_OUTPUT_FILENAME#save output filename as wav extension
         print f
         x=os.popen('mp3info -p "%S" f).read()
         print x
  • 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-26T15:38:58+00:00Added an answer on May 26, 2026 at 3:38 pm
    x=os.popen('mp3info -p "%S" f).read()
    

    is missing a closing quote:

    x=os.popen('mp3info -p "%S" ' + f).read()
    

    You may also want to use the safer subprocess module:

    import subprocess
    x = subprocess.check_output(['mp3info', '-p', '%S', f])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using the following code for loading JQuery in all of my
I have been using the following vector initialization with values in Code::Blocks and MingW
I have been using return by reference to try to speed up my code
I have been using SDL with success to learn OpenGL, however I am following
I have been using a mp3 file in my application for over 3 weeks
I have been using jQuery for a while. I wanted to use the parent()
I have been using Sandcastle along with the Sandcastle Help File Builder and by
I have been using the following regex to replace all punctuation in a string:
I have been using LLVM and I was confused how to use a different
I have been using open_uri to pull down an ftp path as a data

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.