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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:34:02+00:00 2026-05-24T20:34:02+00:00

In a for loop like this one: for f in `ls *.avi`; do echo

  • 0

In a for loop like this one:

for f in `ls *.avi`; do echo $f; ffmpeg -i $f $f.mp3; done

$f will be the complete filename, including the extension. For example, for song1.avi the output of the command will be song1.avi.mp3. Is there a way to get only song1, without the .avi from the for loop?

I imagine there are ways to do that using awk or other such tools, but I’m hoping there’s something more straight forward.

Thanks

  • 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-24T20:34:05+00:00Added an answer on May 24, 2026 at 8:34 pm

    Use bash parameter expansion

    ${f%%.*}
    

    Note that you need the greedy version because there are multiple dots in the file name.

    From bash manual:

    ${parameter%word}

    ${parameter%%word}

    The word is expanded to produce a pattern just as in filename expansion. If the pattern matches a trailing portion of the expanded value of parameter, then the result of the expansion is the value of parameter with the shortest matching pattern (the ‘%’ case) or the longest matching pattern (the ‘%%’ case) deleted. If parameter is ‘@’ or ‘’, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘’, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.

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

Sidebar

Related Questions

Say I have a simple PHP loop like this one // Bad example $array
I would like to use mod_rewrite to transform a URL like this one: http://example.com/qxs/app/myapp.qxs
I have a loop like this: for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write
I know that in JavaScript, creating a for loop like this: for(int i =
I've found in a Module a for-loop written like this for( @array ) {
I have two nested loop in XSL like this, at this moment I use
I know I can loop through a list of strings like this: list<string>::iterator Iterator;
Hi I want to use gawk in a for loop. Something like this: for
I have an array like this (one dimension only): $arr = array('one', 'two', 'three',
I've read a few other posts like this one about avoiding repetition in Java

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.