Convert all found m4a to mp3

Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I'm trying to covert all m4a to mp3 my code look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3";
done
but it only work for first mp3 file for next it show error:
Parse error, at least 3 arguments were expected, only 1 given in string '<All files in one line>'
Enter command: <target>|all <time>|-1 <command>[ <argument>]
The files contain spaces ampersands and parenthesis.
bash ffmpeg
add a comment |Â
up vote
3
down vote
favorite
I'm trying to covert all m4a to mp3 my code look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3";
done
but it only work for first mp3 file for next it show error:
Parse error, at least 3 arguments were expected, only 1 given in string '<All files in one line>'
Enter command: <target>|all <time>|-1 <command>[ <argument>]
The files contain spaces ampersands and parenthesis.
bash ffmpeg
2
You could replaceffmpegwithecho --and inspect the output to ensure all is right.
â thecarpy
Apr 20 at 12:44
setIFSto the null string as well... |while IFS= read -d '' -r file; .... You could use all withfindinstead of using a shell while-loop
â Ã±ÃÂsýù÷
Apr 20 at 14:47
@thecarpy I was testing with echo and I've got each file with its own ffmpeg
â jcubic
Apr 20 at 15:33
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm trying to covert all m4a to mp3 my code look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3";
done
but it only work for first mp3 file for next it show error:
Parse error, at least 3 arguments were expected, only 1 given in string '<All files in one line>'
Enter command: <target>|all <time>|-1 <command>[ <argument>]
The files contain spaces ampersands and parenthesis.
bash ffmpeg
I'm trying to covert all m4a to mp3 my code look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3";
done
but it only work for first mp3 file for next it show error:
Parse error, at least 3 arguments were expected, only 1 given in string '<All files in one line>'
Enter command: <target>|all <time>|-1 <command>[ <argument>]
The files contain spaces ampersands and parenthesis.
bash ffmpeg
asked Apr 20 at 12:28
jcubic
2,67342439
2,67342439
2
You could replaceffmpegwithecho --and inspect the output to ensure all is right.
â thecarpy
Apr 20 at 12:44
setIFSto the null string as well... |while IFS= read -d '' -r file; .... You could use all withfindinstead of using a shell while-loop
â Ã±ÃÂsýù÷
Apr 20 at 14:47
@thecarpy I was testing with echo and I've got each file with its own ffmpeg
â jcubic
Apr 20 at 15:33
add a comment |Â
2
You could replaceffmpegwithecho --and inspect the output to ensure all is right.
â thecarpy
Apr 20 at 12:44
setIFSto the null string as well... |while IFS= read -d '' -r file; .... You could use all withfindinstead of using a shell while-loop
â Ã±ÃÂsýù÷
Apr 20 at 14:47
@thecarpy I was testing with echo and I've got each file with its own ffmpeg
â jcubic
Apr 20 at 15:33
2
2
You could replace
ffmpeg with echo -- and inspect the output to ensure all is right.â thecarpy
Apr 20 at 12:44
You could replace
ffmpeg with echo -- and inspect the output to ensure all is right.â thecarpy
Apr 20 at 12:44
set
IFS to the null string as well ... |while IFS= read -d '' -r file; ... . You could use all with find instead of using a shell while-loopâ Ã±ÃÂsýù÷
Apr 20 at 14:47
set
IFS to the null string as well ... |while IFS= read -d '' -r file; ... . You could use all with find instead of using a shell while-loopâ Ã±ÃÂsýù÷
Apr 20 at 14:47
@thecarpy I was testing with echo and I've got each file with its own ffmpeg
â jcubic
Apr 20 at 15:33
@thecarpy I was testing with echo and I've got each file with its own ffmpeg
â jcubic
Apr 20 at 15:33
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
4
down vote
accepted
WhenÃÂ reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input file.
Continue reading here: Bash FAQ 89
So the code should look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3" < /dev/null
done
add a comment |Â
up vote
0
down vote
Your question asked about converting m4a to mp3.
This is a bash script I have been using for a while.
Adjust the avconv command to suite your needs.
#!/bin/bash
## jc 2016
## convert [m4a mp3 wma] to mp3 128k
## [-vn] disable video recording
##
## avconv with lame mp3 plugin
## [-acodec libmp3lame]
##
## 192 k constant bitrate
## [-ab 192k]
## [-ab 128k]
##
## 44.1kHz sampling rate
## [-ar 44100]
##
## 2 channel audio
## [-ac 2]
##
## force the shell to do a case insensitive comparison
shopt -s nocasematch
working_directory="./mp3_converted"
# check if dir exist
if [ ! -d "$working_directory" ];
then
# dir does not exist
echo "convert directory does not exist $working_directory..."
`mkdir -p "$working_directory"`
echo "convert directory created $working_directory..."
fi
COUNT=0
for i in *; do
case $i in
*.mp3)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .mp3`.mp3"
echo $i
;;
*.m4a)
##avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .m4a`.mp3"
# adjusted for ffmpeg to test.
ffmpeg -i "$i" -n -acodec libmp3lame -ab 128k "$working_directory/`basename "$i" .m4a`.mp3"
echo $i
;;
*.wma)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .wma`.mp3"
echo $i
;;
*)
echo "other"
;;
esac
done
## back to normal comparison
shopt -u nocasematch
exit 0
add a comment |Â
up vote
0
down vote
Why not just use the -exec argument of find? So find -iname '*.m4a' -exec ffmpeg -i -n -acodec libmp3lame -ab 128k .mp3 ; and run a rename command afterward?
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
WhenÃÂ reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input file.
Continue reading here: Bash FAQ 89
So the code should look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3" < /dev/null
done
add a comment |Â
up vote
4
down vote
accepted
WhenÃÂ reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input file.
Continue reading here: Bash FAQ 89
So the code should look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3" < /dev/null
done
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
WhenÃÂ reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input file.
Continue reading here: Bash FAQ 89
So the code should look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3" < /dev/null
done
WhenÃÂ reading a file line by line, if a command inside the loop also reads stdin, it can exhaust the input file.
Continue reading here: Bash FAQ 89
So the code should look like this:
find . -name '*.m4a' -print0 | while read -d '' -r file; do
ffmpeg -i "$file" -n -acodec libmp3lame -ab 128k "$file%.m4a.mp3" < /dev/null
done
edited Apr 20 at 15:57
jcubic
2,67342439
2,67342439
answered Apr 20 at 14:00
Rany Albeg Wein
567214
567214
add a comment |Â
add a comment |Â
up vote
0
down vote
Your question asked about converting m4a to mp3.
This is a bash script I have been using for a while.
Adjust the avconv command to suite your needs.
#!/bin/bash
## jc 2016
## convert [m4a mp3 wma] to mp3 128k
## [-vn] disable video recording
##
## avconv with lame mp3 plugin
## [-acodec libmp3lame]
##
## 192 k constant bitrate
## [-ab 192k]
## [-ab 128k]
##
## 44.1kHz sampling rate
## [-ar 44100]
##
## 2 channel audio
## [-ac 2]
##
## force the shell to do a case insensitive comparison
shopt -s nocasematch
working_directory="./mp3_converted"
# check if dir exist
if [ ! -d "$working_directory" ];
then
# dir does not exist
echo "convert directory does not exist $working_directory..."
`mkdir -p "$working_directory"`
echo "convert directory created $working_directory..."
fi
COUNT=0
for i in *; do
case $i in
*.mp3)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .mp3`.mp3"
echo $i
;;
*.m4a)
##avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .m4a`.mp3"
# adjusted for ffmpeg to test.
ffmpeg -i "$i" -n -acodec libmp3lame -ab 128k "$working_directory/`basename "$i" .m4a`.mp3"
echo $i
;;
*.wma)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .wma`.mp3"
echo $i
;;
*)
echo "other"
;;
esac
done
## back to normal comparison
shopt -u nocasematch
exit 0
add a comment |Â
up vote
0
down vote
Your question asked about converting m4a to mp3.
This is a bash script I have been using for a while.
Adjust the avconv command to suite your needs.
#!/bin/bash
## jc 2016
## convert [m4a mp3 wma] to mp3 128k
## [-vn] disable video recording
##
## avconv with lame mp3 plugin
## [-acodec libmp3lame]
##
## 192 k constant bitrate
## [-ab 192k]
## [-ab 128k]
##
## 44.1kHz sampling rate
## [-ar 44100]
##
## 2 channel audio
## [-ac 2]
##
## force the shell to do a case insensitive comparison
shopt -s nocasematch
working_directory="./mp3_converted"
# check if dir exist
if [ ! -d "$working_directory" ];
then
# dir does not exist
echo "convert directory does not exist $working_directory..."
`mkdir -p "$working_directory"`
echo "convert directory created $working_directory..."
fi
COUNT=0
for i in *; do
case $i in
*.mp3)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .mp3`.mp3"
echo $i
;;
*.m4a)
##avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .m4a`.mp3"
# adjusted for ffmpeg to test.
ffmpeg -i "$i" -n -acodec libmp3lame -ab 128k "$working_directory/`basename "$i" .m4a`.mp3"
echo $i
;;
*.wma)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .wma`.mp3"
echo $i
;;
*)
echo "other"
;;
esac
done
## back to normal comparison
shopt -u nocasematch
exit 0
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Your question asked about converting m4a to mp3.
This is a bash script I have been using for a while.
Adjust the avconv command to suite your needs.
#!/bin/bash
## jc 2016
## convert [m4a mp3 wma] to mp3 128k
## [-vn] disable video recording
##
## avconv with lame mp3 plugin
## [-acodec libmp3lame]
##
## 192 k constant bitrate
## [-ab 192k]
## [-ab 128k]
##
## 44.1kHz sampling rate
## [-ar 44100]
##
## 2 channel audio
## [-ac 2]
##
## force the shell to do a case insensitive comparison
shopt -s nocasematch
working_directory="./mp3_converted"
# check if dir exist
if [ ! -d "$working_directory" ];
then
# dir does not exist
echo "convert directory does not exist $working_directory..."
`mkdir -p "$working_directory"`
echo "convert directory created $working_directory..."
fi
COUNT=0
for i in *; do
case $i in
*.mp3)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .mp3`.mp3"
echo $i
;;
*.m4a)
##avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .m4a`.mp3"
# adjusted for ffmpeg to test.
ffmpeg -i "$i" -n -acodec libmp3lame -ab 128k "$working_directory/`basename "$i" .m4a`.mp3"
echo $i
;;
*.wma)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .wma`.mp3"
echo $i
;;
*)
echo "other"
;;
esac
done
## back to normal comparison
shopt -u nocasematch
exit 0
Your question asked about converting m4a to mp3.
This is a bash script I have been using for a while.
Adjust the avconv command to suite your needs.
#!/bin/bash
## jc 2016
## convert [m4a mp3 wma] to mp3 128k
## [-vn] disable video recording
##
## avconv with lame mp3 plugin
## [-acodec libmp3lame]
##
## 192 k constant bitrate
## [-ab 192k]
## [-ab 128k]
##
## 44.1kHz sampling rate
## [-ar 44100]
##
## 2 channel audio
## [-ac 2]
##
## force the shell to do a case insensitive comparison
shopt -s nocasematch
working_directory="./mp3_converted"
# check if dir exist
if [ ! -d "$working_directory" ];
then
# dir does not exist
echo "convert directory does not exist $working_directory..."
`mkdir -p "$working_directory"`
echo "convert directory created $working_directory..."
fi
COUNT=0
for i in *; do
case $i in
*.mp3)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .mp3`.mp3"
echo $i
;;
*.m4a)
##avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .m4a`.mp3"
# adjusted for ffmpeg to test.
ffmpeg -i "$i" -n -acodec libmp3lame -ab 128k "$working_directory/`basename "$i" .m4a`.mp3"
echo $i
;;
*.wma)
avconv -analyzeduration 999999999 -map_metadata 0 -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$working_directory/`basename "$i" .wma`.mp3"
echo $i
;;
*)
echo "other"
;;
esac
done
## back to normal comparison
shopt -u nocasematch
exit 0
edited Apr 20 at 16:18
answered Apr 20 at 16:03
jc__
1,278215
1,278215
add a comment |Â
add a comment |Â
up vote
0
down vote
Why not just use the -exec argument of find? So find -iname '*.m4a' -exec ffmpeg -i -n -acodec libmp3lame -ab 128k .mp3 ; and run a rename command afterward?
add a comment |Â
up vote
0
down vote
Why not just use the -exec argument of find? So find -iname '*.m4a' -exec ffmpeg -i -n -acodec libmp3lame -ab 128k .mp3 ; and run a rename command afterward?
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Why not just use the -exec argument of find? So find -iname '*.m4a' -exec ffmpeg -i -n -acodec libmp3lame -ab 128k .mp3 ; and run a rename command afterward?
Why not just use the -exec argument of find? So find -iname '*.m4a' -exec ffmpeg -i -n -acodec libmp3lame -ab 128k .mp3 ; and run a rename command afterward?
answered Apr 21 at 11:16
Chiraag
1968
1968
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438927%2fconvert-all-found-m4a-to-mp3%23new-answer', 'question_page');
);
Post as a guest
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
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
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
2
You could replace
ffmpegwithecho --and inspect the output to ensure all is right.â thecarpy
Apr 20 at 12:44
set
IFSto the null string as well... |while IFS= read -d '' -r file; .... You could use all withfindinstead of using a shell while-loopâ Ã±ÃÂsýù÷
Apr 20 at 14:47
@thecarpy I was testing with echo and I've got each file with its own ffmpeg
â jcubic
Apr 20 at 15:33