Search mp3 collection for songs with a certain song length

Clash Royale CLAN TAG#URR8PPP
How would I search a directory of mp3 files for songs between a certain length. Ex:
findmp3 -min=03:00 -max=03:15 /music/mp3/ebm/
Would return all mp3 files in the emb/ directory having a song length between 3:00 and 3:15 minutes in length.
I use Linux Mint, Ubuntu, as well as CentOS.
find mp3
add a comment |
How would I search a directory of mp3 files for songs between a certain length. Ex:
findmp3 -min=03:00 -max=03:15 /music/mp3/ebm/
Would return all mp3 files in the emb/ directory having a song length between 3:00 and 3:15 minutes in length.
I use Linux Mint, Ubuntu, as well as CentOS.
find mp3
Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Unix, Linux, BSD, OSX, something else? Which version?
– terdon♦
Oct 13 '13 at 20:06
added to question.
– a coder
Oct 14 '13 at 14:50
add a comment |
How would I search a directory of mp3 files for songs between a certain length. Ex:
findmp3 -min=03:00 -max=03:15 /music/mp3/ebm/
Would return all mp3 files in the emb/ directory having a song length between 3:00 and 3:15 minutes in length.
I use Linux Mint, Ubuntu, as well as CentOS.
find mp3
How would I search a directory of mp3 files for songs between a certain length. Ex:
findmp3 -min=03:00 -max=03:15 /music/mp3/ebm/
Would return all mp3 files in the emb/ directory having a song length between 3:00 and 3:15 minutes in length.
I use Linux Mint, Ubuntu, as well as CentOS.
find mp3
find mp3
edited Oct 14 '13 at 14:50
a coder
asked Oct 13 '13 at 19:51
a codera coder
1,01972747
1,01972747
Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Unix, Linux, BSD, OSX, something else? Which version?
– terdon♦
Oct 13 '13 at 20:06
added to question.
– a coder
Oct 14 '13 at 14:50
add a comment |
Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Unix, Linux, BSD, OSX, something else? Which version?
– terdon♦
Oct 13 '13 at 20:06
added to question.
– a coder
Oct 14 '13 at 14:50
Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Unix, Linux, BSD, OSX, something else? Which version?
– terdon♦
Oct 13 '13 at 20:06
Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Unix, Linux, BSD, OSX, something else? Which version?
– terdon♦
Oct 13 '13 at 20:06
added to question.
– a coder
Oct 14 '13 at 14:50
added to question.
– a coder
Oct 14 '13 at 14:50
add a comment |
4 Answers
4
active
oldest
votes
First install mp3info, it should be in the repositories of your distribution (you have not said, so I assume you are using Linux of some sort). If you have a debian-based distribution, you can do so with
sudo apt-get install mp3info
Once mp3info is installed, you can search the directory music for songs of a certain length with this command:
find music/ -name "*mp3" |
while IFS= read -r f; do
length=$(mp3info -p "%S" "$f");
if [[ "$length" -ge "180" && "$length" -le "195" ]]; then
echo "$f";
fi;
done
The command above will search music/ for mp3 files, and print their name and length if that length is grater or equal to 180 seconds (3:00) and less than or equal to 195 seconds (3:15). See man mp3info for more details on its output format.
If you want to be able to enter times in MM:SS format, it gets a bit more complex:
#!/usr/bin/env bash
## Convert MM:SS to seconds.
## The date is random, you can use your birthday if you want.
## The important part is not specifying a time so that 00:00:00
## is returned.
d=$(date -d "1/1/2013" +%s);
## Now add the number of minutes and seconds
## you give as the first argument
min=$(date -d "1/1/2013 00:$1" +%s);
## The same for the second arument
max=$(date -d "1/1/2013 00:$2" +%s);
## Search the target directory for files
## of the correct length.
find "$3" -name "*mp3" |
while IFS= read -r file; do
length=$(mp3info -p "%m:%s" "$file");
## Convert the actual length of the song (mm:ss format)
## to seconds so it can be compared.
lengthsec=$(date -d "1/1/2013 00:$length" +%s);
## Compare the length to the $min and $max
if [[ ($lengthsec -ge $min ) && ($lengthsec -le $max ) ]]; then
echo "$file";
fi;
done
Save the script above as findmp3 and run it like this:
findmp3 3:00 3:15 music/
This works nicely. I modified your script to include the length of each song as it loops through the directories.
– a coder
Oct 14 '13 at 15:38
@acoder lol, I had that too at the beginning and removed it as unneeded :).
– terdon♦
Oct 14 '13 at 15:42
Btw here is my modified script: pastebin.com/ykYJiC6Q
– a coder
Jan 25 at 15:57
add a comment |
I doubt that there's an existing findmp3 tool. Following the unix philosophy, it can be built from find to find .mp3 files, another tool to report the length of each file that find finds, and some shell/text processing glue.
SoX is a commonly available utility to work with sound files (sox is to sound what sed or awk are to text files). The command soxi displays information about a sound file. In particular, soxi -D prints the duration in seconds.
For each .mp3 file, the snippet below calls soxi and parses its output. If the duration is within the desired range, the sh call returns a success status, so the -print action is executed to print the file name.
find /music/mp3/ebm -type f -name .mp3 -exec sh -c '
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds
[ $((d >= 3*60 && d < 3*60+15)) -eq 1 ]
' ; -print
In bash, ksh93 or zsh, you can use recursive globbing instead of find. In ksh, run set -o globstar first. In bash, run shopt -s globstar first. Note that in bash (but not in ksh or zsh), **/ recurses through symbolic links to directories.
for f in /music/mp3/ebm/**/*.mp3; do
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds (needed in bash only, ksh93 and zsh understand floating point numbers)
if ((d >= 3*60 && d < 3*60+15)); then
echo "$f"
fi
done
of course, your soxi should be suppor mp3 format.thank you Gilles.
– PersianGulf
Oct 13 '13 at 22:02
add a comment |
Using ffmpeg:
find . -name *.mp3|while IFS= read -r l;do ffprobe -v 0 -i "$l" -show_streams|awk -F= '$1=="duration"&&$2>=180&&$2<=195'|read&&echo "$l";done
mp3info oneliner:
find . -name *.mp3 -exec mp3info -p '%S %fn' +|awk '$1>=180&&$1<=195'|cut -d' ' -f2-
Or in OS X:
mdfind 'kMDItemDurationSeconds>=180&&kMDItemDurationSeconds<=195&&kMDItemContentType=public.mp3' -onlyin .
add a comment |
ffmpeg -i yourmp3.mp3 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
With above command, you can get your duration, So you can script to specify a domain for duration.
Also you can use:
find yourPath -iname "*mp3" -exec ffmpeg -i 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
Replace yourPath with root of your mp3 repository.
1
This doesn't answer the question (though it's certainly a good starting point for the script that would be necessary), and you'd be better off using ffprobe's-show_formatoption, like:ffprobe -show_format -i file.mp3 | sed -n '/duration/s/.*=//p'
– evilsoup
Oct 13 '13 at 21:44
i doapt-file search ffprobeand i didn't any result on sid debian repository.
– PersianGulf
Oct 13 '13 at 21:57
Strange, it is part of thelibav-toolspackage.
– terdon♦
Oct 13 '13 at 22:14
Are you sure? wich distro?i installed libav-tools, but it has avprobe, Do you mean avprobe?
– PersianGulf
Oct 13 '13 at 22:42
No. He meansffprobe. It is not part of unstable. Removed back in 2011. E.g. for i386 stable vs. unstable
– Runium
Oct 13 '13 at 23:31
|
show 2 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f95890%2fsearch-mp3-collection-for-songs-with-a-certain-song-length%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
First install mp3info, it should be in the repositories of your distribution (you have not said, so I assume you are using Linux of some sort). If you have a debian-based distribution, you can do so with
sudo apt-get install mp3info
Once mp3info is installed, you can search the directory music for songs of a certain length with this command:
find music/ -name "*mp3" |
while IFS= read -r f; do
length=$(mp3info -p "%S" "$f");
if [[ "$length" -ge "180" && "$length" -le "195" ]]; then
echo "$f";
fi;
done
The command above will search music/ for mp3 files, and print their name and length if that length is grater or equal to 180 seconds (3:00) and less than or equal to 195 seconds (3:15). See man mp3info for more details on its output format.
If you want to be able to enter times in MM:SS format, it gets a bit more complex:
#!/usr/bin/env bash
## Convert MM:SS to seconds.
## The date is random, you can use your birthday if you want.
## The important part is not specifying a time so that 00:00:00
## is returned.
d=$(date -d "1/1/2013" +%s);
## Now add the number of minutes and seconds
## you give as the first argument
min=$(date -d "1/1/2013 00:$1" +%s);
## The same for the second arument
max=$(date -d "1/1/2013 00:$2" +%s);
## Search the target directory for files
## of the correct length.
find "$3" -name "*mp3" |
while IFS= read -r file; do
length=$(mp3info -p "%m:%s" "$file");
## Convert the actual length of the song (mm:ss format)
## to seconds so it can be compared.
lengthsec=$(date -d "1/1/2013 00:$length" +%s);
## Compare the length to the $min and $max
if [[ ($lengthsec -ge $min ) && ($lengthsec -le $max ) ]]; then
echo "$file";
fi;
done
Save the script above as findmp3 and run it like this:
findmp3 3:00 3:15 music/
This works nicely. I modified your script to include the length of each song as it loops through the directories.
– a coder
Oct 14 '13 at 15:38
@acoder lol, I had that too at the beginning and removed it as unneeded :).
– terdon♦
Oct 14 '13 at 15:42
Btw here is my modified script: pastebin.com/ykYJiC6Q
– a coder
Jan 25 at 15:57
add a comment |
First install mp3info, it should be in the repositories of your distribution (you have not said, so I assume you are using Linux of some sort). If you have a debian-based distribution, you can do so with
sudo apt-get install mp3info
Once mp3info is installed, you can search the directory music for songs of a certain length with this command:
find music/ -name "*mp3" |
while IFS= read -r f; do
length=$(mp3info -p "%S" "$f");
if [[ "$length" -ge "180" && "$length" -le "195" ]]; then
echo "$f";
fi;
done
The command above will search music/ for mp3 files, and print their name and length if that length is grater or equal to 180 seconds (3:00) and less than or equal to 195 seconds (3:15). See man mp3info for more details on its output format.
If you want to be able to enter times in MM:SS format, it gets a bit more complex:
#!/usr/bin/env bash
## Convert MM:SS to seconds.
## The date is random, you can use your birthday if you want.
## The important part is not specifying a time so that 00:00:00
## is returned.
d=$(date -d "1/1/2013" +%s);
## Now add the number of minutes and seconds
## you give as the first argument
min=$(date -d "1/1/2013 00:$1" +%s);
## The same for the second arument
max=$(date -d "1/1/2013 00:$2" +%s);
## Search the target directory for files
## of the correct length.
find "$3" -name "*mp3" |
while IFS= read -r file; do
length=$(mp3info -p "%m:%s" "$file");
## Convert the actual length of the song (mm:ss format)
## to seconds so it can be compared.
lengthsec=$(date -d "1/1/2013 00:$length" +%s);
## Compare the length to the $min and $max
if [[ ($lengthsec -ge $min ) && ($lengthsec -le $max ) ]]; then
echo "$file";
fi;
done
Save the script above as findmp3 and run it like this:
findmp3 3:00 3:15 music/
This works nicely. I modified your script to include the length of each song as it loops through the directories.
– a coder
Oct 14 '13 at 15:38
@acoder lol, I had that too at the beginning and removed it as unneeded :).
– terdon♦
Oct 14 '13 at 15:42
Btw here is my modified script: pastebin.com/ykYJiC6Q
– a coder
Jan 25 at 15:57
add a comment |
First install mp3info, it should be in the repositories of your distribution (you have not said, so I assume you are using Linux of some sort). If you have a debian-based distribution, you can do so with
sudo apt-get install mp3info
Once mp3info is installed, you can search the directory music for songs of a certain length with this command:
find music/ -name "*mp3" |
while IFS= read -r f; do
length=$(mp3info -p "%S" "$f");
if [[ "$length" -ge "180" && "$length" -le "195" ]]; then
echo "$f";
fi;
done
The command above will search music/ for mp3 files, and print their name and length if that length is grater or equal to 180 seconds (3:00) and less than or equal to 195 seconds (3:15). See man mp3info for more details on its output format.
If you want to be able to enter times in MM:SS format, it gets a bit more complex:
#!/usr/bin/env bash
## Convert MM:SS to seconds.
## The date is random, you can use your birthday if you want.
## The important part is not specifying a time so that 00:00:00
## is returned.
d=$(date -d "1/1/2013" +%s);
## Now add the number of minutes and seconds
## you give as the first argument
min=$(date -d "1/1/2013 00:$1" +%s);
## The same for the second arument
max=$(date -d "1/1/2013 00:$2" +%s);
## Search the target directory for files
## of the correct length.
find "$3" -name "*mp3" |
while IFS= read -r file; do
length=$(mp3info -p "%m:%s" "$file");
## Convert the actual length of the song (mm:ss format)
## to seconds so it can be compared.
lengthsec=$(date -d "1/1/2013 00:$length" +%s);
## Compare the length to the $min and $max
if [[ ($lengthsec -ge $min ) && ($lengthsec -le $max ) ]]; then
echo "$file";
fi;
done
Save the script above as findmp3 and run it like this:
findmp3 3:00 3:15 music/
First install mp3info, it should be in the repositories of your distribution (you have not said, so I assume you are using Linux of some sort). If you have a debian-based distribution, you can do so with
sudo apt-get install mp3info
Once mp3info is installed, you can search the directory music for songs of a certain length with this command:
find music/ -name "*mp3" |
while IFS= read -r f; do
length=$(mp3info -p "%S" "$f");
if [[ "$length" -ge "180" && "$length" -le "195" ]]; then
echo "$f";
fi;
done
The command above will search music/ for mp3 files, and print their name and length if that length is grater or equal to 180 seconds (3:00) and less than or equal to 195 seconds (3:15). See man mp3info for more details on its output format.
If you want to be able to enter times in MM:SS format, it gets a bit more complex:
#!/usr/bin/env bash
## Convert MM:SS to seconds.
## The date is random, you can use your birthday if you want.
## The important part is not specifying a time so that 00:00:00
## is returned.
d=$(date -d "1/1/2013" +%s);
## Now add the number of minutes and seconds
## you give as the first argument
min=$(date -d "1/1/2013 00:$1" +%s);
## The same for the second arument
max=$(date -d "1/1/2013 00:$2" +%s);
## Search the target directory for files
## of the correct length.
find "$3" -name "*mp3" |
while IFS= read -r file; do
length=$(mp3info -p "%m:%s" "$file");
## Convert the actual length of the song (mm:ss format)
## to seconds so it can be compared.
lengthsec=$(date -d "1/1/2013 00:$length" +%s);
## Compare the length to the $min and $max
if [[ ($lengthsec -ge $min ) && ($lengthsec -le $max ) ]]; then
echo "$file";
fi;
done
Save the script above as findmp3 and run it like this:
findmp3 3:00 3:15 music/
edited Jan 25 at 16:02
answered Oct 13 '13 at 22:11
terdon♦terdon
130k32255433
130k32255433
This works nicely. I modified your script to include the length of each song as it loops through the directories.
– a coder
Oct 14 '13 at 15:38
@acoder lol, I had that too at the beginning and removed it as unneeded :).
– terdon♦
Oct 14 '13 at 15:42
Btw here is my modified script: pastebin.com/ykYJiC6Q
– a coder
Jan 25 at 15:57
add a comment |
This works nicely. I modified your script to include the length of each song as it loops through the directories.
– a coder
Oct 14 '13 at 15:38
@acoder lol, I had that too at the beginning and removed it as unneeded :).
– terdon♦
Oct 14 '13 at 15:42
Btw here is my modified script: pastebin.com/ykYJiC6Q
– a coder
Jan 25 at 15:57
This works nicely. I modified your script to include the length of each song as it loops through the directories.
– a coder
Oct 14 '13 at 15:38
This works nicely. I modified your script to include the length of each song as it loops through the directories.
– a coder
Oct 14 '13 at 15:38
@acoder lol, I had that too at the beginning and removed it as unneeded :).
– terdon♦
Oct 14 '13 at 15:42
@acoder lol, I had that too at the beginning and removed it as unneeded :).
– terdon♦
Oct 14 '13 at 15:42
Btw here is my modified script: pastebin.com/ykYJiC6Q
– a coder
Jan 25 at 15:57
Btw here is my modified script: pastebin.com/ykYJiC6Q
– a coder
Jan 25 at 15:57
add a comment |
I doubt that there's an existing findmp3 tool. Following the unix philosophy, it can be built from find to find .mp3 files, another tool to report the length of each file that find finds, and some shell/text processing glue.
SoX is a commonly available utility to work with sound files (sox is to sound what sed or awk are to text files). The command soxi displays information about a sound file. In particular, soxi -D prints the duration in seconds.
For each .mp3 file, the snippet below calls soxi and parses its output. If the duration is within the desired range, the sh call returns a success status, so the -print action is executed to print the file name.
find /music/mp3/ebm -type f -name .mp3 -exec sh -c '
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds
[ $((d >= 3*60 && d < 3*60+15)) -eq 1 ]
' ; -print
In bash, ksh93 or zsh, you can use recursive globbing instead of find. In ksh, run set -o globstar first. In bash, run shopt -s globstar first. Note that in bash (but not in ksh or zsh), **/ recurses through symbolic links to directories.
for f in /music/mp3/ebm/**/*.mp3; do
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds (needed in bash only, ksh93 and zsh understand floating point numbers)
if ((d >= 3*60 && d < 3*60+15)); then
echo "$f"
fi
done
of course, your soxi should be suppor mp3 format.thank you Gilles.
– PersianGulf
Oct 13 '13 at 22:02
add a comment |
I doubt that there's an existing findmp3 tool. Following the unix philosophy, it can be built from find to find .mp3 files, another tool to report the length of each file that find finds, and some shell/text processing glue.
SoX is a commonly available utility to work with sound files (sox is to sound what sed or awk are to text files). The command soxi displays information about a sound file. In particular, soxi -D prints the duration in seconds.
For each .mp3 file, the snippet below calls soxi and parses its output. If the duration is within the desired range, the sh call returns a success status, so the -print action is executed to print the file name.
find /music/mp3/ebm -type f -name .mp3 -exec sh -c '
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds
[ $((d >= 3*60 && d < 3*60+15)) -eq 1 ]
' ; -print
In bash, ksh93 or zsh, you can use recursive globbing instead of find. In ksh, run set -o globstar first. In bash, run shopt -s globstar first. Note that in bash (but not in ksh or zsh), **/ recurses through symbolic links to directories.
for f in /music/mp3/ebm/**/*.mp3; do
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds (needed in bash only, ksh93 and zsh understand floating point numbers)
if ((d >= 3*60 && d < 3*60+15)); then
echo "$f"
fi
done
of course, your soxi should be suppor mp3 format.thank you Gilles.
– PersianGulf
Oct 13 '13 at 22:02
add a comment |
I doubt that there's an existing findmp3 tool. Following the unix philosophy, it can be built from find to find .mp3 files, another tool to report the length of each file that find finds, and some shell/text processing glue.
SoX is a commonly available utility to work with sound files (sox is to sound what sed or awk are to text files). The command soxi displays information about a sound file. In particular, soxi -D prints the duration in seconds.
For each .mp3 file, the snippet below calls soxi and parses its output. If the duration is within the desired range, the sh call returns a success status, so the -print action is executed to print the file name.
find /music/mp3/ebm -type f -name .mp3 -exec sh -c '
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds
[ $((d >= 3*60 && d < 3*60+15)) -eq 1 ]
' ; -print
In bash, ksh93 or zsh, you can use recursive globbing instead of find. In ksh, run set -o globstar first. In bash, run shopt -s globstar first. Note that in bash (but not in ksh or zsh), **/ recurses through symbolic links to directories.
for f in /music/mp3/ebm/**/*.mp3; do
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds (needed in bash only, ksh93 and zsh understand floating point numbers)
if ((d >= 3*60 && d < 3*60+15)); then
echo "$f"
fi
done
I doubt that there's an existing findmp3 tool. Following the unix philosophy, it can be built from find to find .mp3 files, another tool to report the length of each file that find finds, and some shell/text processing glue.
SoX is a commonly available utility to work with sound files (sox is to sound what sed or awk are to text files). The command soxi displays information about a sound file. In particular, soxi -D prints the duration in seconds.
For each .mp3 file, the snippet below calls soxi and parses its output. If the duration is within the desired range, the sh call returns a success status, so the -print action is executed to print the file name.
find /music/mp3/ebm -type f -name .mp3 -exec sh -c '
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds
[ $((d >= 3*60 && d < 3*60+15)) -eq 1 ]
' ; -print
In bash, ksh93 or zsh, you can use recursive globbing instead of find. In ksh, run set -o globstar first. In bash, run shopt -s globstar first. Note that in bash (but not in ksh or zsh), **/ recurses through symbolic links to directories.
for f in /music/mp3/ebm/**/*.mp3; do
d=$(soxi -D "$0")
d=$d%.* # truncate to an integer number of seconds (needed in bash only, ksh93 and zsh understand floating point numbers)
if ((d >= 3*60 && d < 3*60+15)); then
echo "$f"
fi
done
answered Oct 13 '13 at 21:52
GillesGilles
537k12810831602
537k12810831602
of course, your soxi should be suppor mp3 format.thank you Gilles.
– PersianGulf
Oct 13 '13 at 22:02
add a comment |
of course, your soxi should be suppor mp3 format.thank you Gilles.
– PersianGulf
Oct 13 '13 at 22:02
of course, your soxi should be suppor mp3 format.thank you Gilles.
– PersianGulf
Oct 13 '13 at 22:02
of course, your soxi should be suppor mp3 format.thank you Gilles.
– PersianGulf
Oct 13 '13 at 22:02
add a comment |
Using ffmpeg:
find . -name *.mp3|while IFS= read -r l;do ffprobe -v 0 -i "$l" -show_streams|awk -F= '$1=="duration"&&$2>=180&&$2<=195'|read&&echo "$l";done
mp3info oneliner:
find . -name *.mp3 -exec mp3info -p '%S %fn' +|awk '$1>=180&&$1<=195'|cut -d' ' -f2-
Or in OS X:
mdfind 'kMDItemDurationSeconds>=180&&kMDItemDurationSeconds<=195&&kMDItemContentType=public.mp3' -onlyin .
add a comment |
Using ffmpeg:
find . -name *.mp3|while IFS= read -r l;do ffprobe -v 0 -i "$l" -show_streams|awk -F= '$1=="duration"&&$2>=180&&$2<=195'|read&&echo "$l";done
mp3info oneliner:
find . -name *.mp3 -exec mp3info -p '%S %fn' +|awk '$1>=180&&$1<=195'|cut -d' ' -f2-
Or in OS X:
mdfind 'kMDItemDurationSeconds>=180&&kMDItemDurationSeconds<=195&&kMDItemContentType=public.mp3' -onlyin .
add a comment |
Using ffmpeg:
find . -name *.mp3|while IFS= read -r l;do ffprobe -v 0 -i "$l" -show_streams|awk -F= '$1=="duration"&&$2>=180&&$2<=195'|read&&echo "$l";done
mp3info oneliner:
find . -name *.mp3 -exec mp3info -p '%S %fn' +|awk '$1>=180&&$1<=195'|cut -d' ' -f2-
Or in OS X:
mdfind 'kMDItemDurationSeconds>=180&&kMDItemDurationSeconds<=195&&kMDItemContentType=public.mp3' -onlyin .
Using ffmpeg:
find . -name *.mp3|while IFS= read -r l;do ffprobe -v 0 -i "$l" -show_streams|awk -F= '$1=="duration"&&$2>=180&&$2<=195'|read&&echo "$l";done
mp3info oneliner:
find . -name *.mp3 -exec mp3info -p '%S %fn' +|awk '$1>=180&&$1<=195'|cut -d' ' -f2-
Or in OS X:
mdfind 'kMDItemDurationSeconds>=180&&kMDItemDurationSeconds<=195&&kMDItemContentType=public.mp3' -onlyin .
answered Jun 17 '14 at 18:49
LriLri
3,32511616
3,32511616
add a comment |
add a comment |
ffmpeg -i yourmp3.mp3 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
With above command, you can get your duration, So you can script to specify a domain for duration.
Also you can use:
find yourPath -iname "*mp3" -exec ffmpeg -i 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
Replace yourPath with root of your mp3 repository.
1
This doesn't answer the question (though it's certainly a good starting point for the script that would be necessary), and you'd be better off using ffprobe's-show_formatoption, like:ffprobe -show_format -i file.mp3 | sed -n '/duration/s/.*=//p'
– evilsoup
Oct 13 '13 at 21:44
i doapt-file search ffprobeand i didn't any result on sid debian repository.
– PersianGulf
Oct 13 '13 at 21:57
Strange, it is part of thelibav-toolspackage.
– terdon♦
Oct 13 '13 at 22:14
Are you sure? wich distro?i installed libav-tools, but it has avprobe, Do you mean avprobe?
– PersianGulf
Oct 13 '13 at 22:42
No. He meansffprobe. It is not part of unstable. Removed back in 2011. E.g. for i386 stable vs. unstable
– Runium
Oct 13 '13 at 23:31
|
show 2 more comments
ffmpeg -i yourmp3.mp3 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
With above command, you can get your duration, So you can script to specify a domain for duration.
Also you can use:
find yourPath -iname "*mp3" -exec ffmpeg -i 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
Replace yourPath with root of your mp3 repository.
1
This doesn't answer the question (though it's certainly a good starting point for the script that would be necessary), and you'd be better off using ffprobe's-show_formatoption, like:ffprobe -show_format -i file.mp3 | sed -n '/duration/s/.*=//p'
– evilsoup
Oct 13 '13 at 21:44
i doapt-file search ffprobeand i didn't any result on sid debian repository.
– PersianGulf
Oct 13 '13 at 21:57
Strange, it is part of thelibav-toolspackage.
– terdon♦
Oct 13 '13 at 22:14
Are you sure? wich distro?i installed libav-tools, but it has avprobe, Do you mean avprobe?
– PersianGulf
Oct 13 '13 at 22:42
No. He meansffprobe. It is not part of unstable. Removed back in 2011. E.g. for i386 stable vs. unstable
– Runium
Oct 13 '13 at 23:31
|
show 2 more comments
ffmpeg -i yourmp3.mp3 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
With above command, you can get your duration, So you can script to specify a domain for duration.
Also you can use:
find yourPath -iname "*mp3" -exec ffmpeg -i 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
Replace yourPath with root of your mp3 repository.
ffmpeg -i yourmp3.mp3 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
With above command, you can get your duration, So you can script to specify a domain for duration.
Also you can use:
find yourPath -iname "*mp3" -exec ffmpeg -i 2>&1 | grep Duration | sed 's/Duration: (.*), start/1/g' |awk 'print $1'
Replace yourPath with root of your mp3 repository.
edited Oct 13 '13 at 21:37
answered Oct 13 '13 at 21:31
PersianGulfPersianGulf
6,97243561
6,97243561
1
This doesn't answer the question (though it's certainly a good starting point for the script that would be necessary), and you'd be better off using ffprobe's-show_formatoption, like:ffprobe -show_format -i file.mp3 | sed -n '/duration/s/.*=//p'
– evilsoup
Oct 13 '13 at 21:44
i doapt-file search ffprobeand i didn't any result on sid debian repository.
– PersianGulf
Oct 13 '13 at 21:57
Strange, it is part of thelibav-toolspackage.
– terdon♦
Oct 13 '13 at 22:14
Are you sure? wich distro?i installed libav-tools, but it has avprobe, Do you mean avprobe?
– PersianGulf
Oct 13 '13 at 22:42
No. He meansffprobe. It is not part of unstable. Removed back in 2011. E.g. for i386 stable vs. unstable
– Runium
Oct 13 '13 at 23:31
|
show 2 more comments
1
This doesn't answer the question (though it's certainly a good starting point for the script that would be necessary), and you'd be better off using ffprobe's-show_formatoption, like:ffprobe -show_format -i file.mp3 | sed -n '/duration/s/.*=//p'
– evilsoup
Oct 13 '13 at 21:44
i doapt-file search ffprobeand i didn't any result on sid debian repository.
– PersianGulf
Oct 13 '13 at 21:57
Strange, it is part of thelibav-toolspackage.
– terdon♦
Oct 13 '13 at 22:14
Are you sure? wich distro?i installed libav-tools, but it has avprobe, Do you mean avprobe?
– PersianGulf
Oct 13 '13 at 22:42
No. He meansffprobe. It is not part of unstable. Removed back in 2011. E.g. for i386 stable vs. unstable
– Runium
Oct 13 '13 at 23:31
1
1
This doesn't answer the question (though it's certainly a good starting point for the script that would be necessary), and you'd be better off using ffprobe's
-show_format option, like: ffprobe -show_format -i file.mp3 | sed -n '/duration/s/.*=//p'– evilsoup
Oct 13 '13 at 21:44
This doesn't answer the question (though it's certainly a good starting point for the script that would be necessary), and you'd be better off using ffprobe's
-show_format option, like: ffprobe -show_format -i file.mp3 | sed -n '/duration/s/.*=//p'– evilsoup
Oct 13 '13 at 21:44
i do
apt-file search ffprobe and i didn't any result on sid debian repository.– PersianGulf
Oct 13 '13 at 21:57
i do
apt-file search ffprobe and i didn't any result on sid debian repository.– PersianGulf
Oct 13 '13 at 21:57
Strange, it is part of the
libav-tools package.– terdon♦
Oct 13 '13 at 22:14
Strange, it is part of the
libav-tools package.– terdon♦
Oct 13 '13 at 22:14
Are you sure? wich distro?i installed libav-tools, but it has avprobe, Do you mean avprobe?
– PersianGulf
Oct 13 '13 at 22:42
Are you sure? wich distro?i installed libav-tools, but it has avprobe, Do you mean avprobe?
– PersianGulf
Oct 13 '13 at 22:42
No. He means
ffprobe. It is not part of unstable. Removed back in 2011. E.g. for i386 stable vs. unstable– Runium
Oct 13 '13 at 23:31
No. He means
ffprobe. It is not part of unstable. Removed back in 2011. E.g. for i386 stable vs. unstable– Runium
Oct 13 '13 at 23:31
|
show 2 more comments
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f95890%2fsearch-mp3-collection-for-songs-with-a-certain-song-length%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Unix, Linux, BSD, OSX, something else? Which version?
– terdon♦
Oct 13 '13 at 20:06
added to question.
– a coder
Oct 14 '13 at 14:50