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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:17:42+00:00 2026-05-23T23:17:42+00:00

I would like to script this command ffmpeg -i concat:file1.mp3\|file2.mp3 -acodec copy output.mp3 which

  • 0

I would like to script this command

ffmpeg -i concat:file1.mp3\|file2.mp3 -acodec copy output.mp3

which merges file1.mp3 and file2.mp3 to become output.mp3.

The problem is that I have a lot more than 2 files that I would like to merge.

Example

ffmpeg -i concat:file1.mp3\|file2.mp3 -acodec copy output1.mp3
ffmpeg -i concat:output1.mp3\|file3.mp3 -acodec copy output2.mp3
ffmpeg -i concat:output2.mp3\|file4.mp3 -acodec copy output3.mp3
ffmpeg -i concat:output3.mp3\|file5.mp3 -acodec copy output4.mp3

output4.mp3 is the result I am looking for.

The files are not actually nicely called “file” adn then a number, but ls lists them in the order they should be merged in.

Question

How can this be scripted, so I can execute it in a directory with either an even or odd number of files?

  • 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-23T23:17:43+00:00Added an answer on May 23, 2026 at 11:17 pm

    if ffmpeg supports more then two files and no file contains |, and there are not too many, you can do:
    ffmpeg -i concat:"$(ls|tr '\n' '|')" -acodec copy out.mp3

    if not:

    for cfile in *.mp3; do
      ffmpeg -i concat:myout.mp3tmp1\|$cfile -acodec copy myout.mp3tmp2
      mv myout.mp3tmp2 myout.mp3tmp1
    done
    mv myout.mp3tmp1 <your final file name>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script. I would like to give this script a quiet mode
Are there any good reasons for why you would include JavaScript like this: <script
I would like to automate the following svn command. Note this command produces the
I would like to create a php script to execute a shell command and
Have this upload script, and it works. But I would like to add a
I'm listing just the file basenames with an ls command like this, which I
I have this sql script that I would like to execute in a java
I would like my script to act differently in an interactive shell session and
I would like to script telnet to test my website inputs handling. I can
I would like my python script to search through a directory in SVN, locate

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.