Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using mp3splt to split all the .mp3 files under a directory, including subdirectories, into 30 minute slices.

find -name *.mp3 -print0 | xargs -0  mp3splt -t 30.00 -o @f_@m@s

What is the best way to delete the original file after the splitting is complete?

share|improve this question
up vote 1 down vote accepted

Create and chmod +x the following script,

#!/usr/bin/env bash
mp3splt -t 30.00 -o @f_@m@s "$@"
rm "$@"

Then you can run

find -name *.mp3 -print0 | xargs -0 /path/to/

You could also try something like the following, but it'll create separate invocations of mp3splt:

find -name "*.mp3" -exec mp3split -t 30.00 -o @f_@m@s {} \; -a -delete

This requires mp3split to return a exit code of 0, indicating success.

share|improve this answer
The first solution works just fine for me. I traversing the subdirectories is a requirement. – Garrett Rowe Dec 2 '11 at 7:35

As a quick fix try:

for file in *.mp3
mp3splt -t 30.0.0 -o @f_@m@s "$file"
rm -f "$file"
share|improve this answer
@DanielBeck I have updated the answer. I think the added quotes do the trick. – Sachin Divekar Dec 2 '11 at 6:36
I think so too, yes. Now you don't handle files in subdirectories, which are also returned by find without -maxdepth. Can't say if it's an issue for the user though. – Daniel Beck Dec 2 '11 at 6:38
@DanielBeck that's why I have added quick fix. We can add many more sophistications. And user himself have find without maxdepth. – Sachin Divekar Dec 2 '11 at 6:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.