How do you convert an entire directory with ffmpeg?
How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?
ffmpeg batch-processing
add a comment |
How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?
ffmpeg batch-processing
add a comment |
How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?
ffmpeg batch-processing
How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?
ffmpeg batch-processing
ffmpeg batch-processing
edited Apr 11 '16 at 0:23
asked Apr 26 '11 at 0:19
Eugene
4,235154772
4,235154772
add a comment |
add a comment |
12 Answers
12
active
oldest
votes
Previous answer will only create 1 output file called out.mov. To make a separate output file for each old movie, try this.
for i in *.avi;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" "${name}.mov";
done
19
If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov";
– Pif
Dec 17 '12 at 22:36
5
I'm getting the errori was unexpected at this time.
– Keavon
May 17 '14 at 1:09
4
do name=`echo "${i%.*}"`;
will work on file names with dots (and spaces) in them.
– Nepoxx
Jun 30 '15 at 14:50
4
Wow, this answer is incredibly overcomplicated. See one of the one-line answers.
– foobarbecue
Jun 11 '16 at 18:49
is this support for.bat
in windows?
– Jazuly
Jun 30 '18 at 6:12
|
show 2 more comments
For Linux and macOS this can be done in one line, using parameter expansion to change the filename extension of the output file:
for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done
This is perfect, thank you! Here's full command that ended up working great for me: for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
– Phil Kulak
Apr 28 '17 at 3:29
I am gettingi was unexpected at this time.
error in cmd, windows 10. I used following line:for i in *.mp3; do ffmpeg -i "$i" -map_metadata -1 -c:v copy -c:a copy "${i%.mp3}.mp3"; done
– Junaid
May 17 '17 at 7:13
1
@Junaid 1) Make sure to use a different name for the output file than the input, or output to another directory, becauseffmpeg
can't input and output to the same file. 2) I'm not sure if Bash commands work on Windows 10 natively. Maybe I should add to the answer that it is targeted towards systems that can natively use Bash such as Linux and macOS. lxs provided an Windows answer for this question.
– llogan
May 17 '17 at 17:25
I suggest this is marked as the correct answer.
– Alexandr Kurilin
Apr 25 '18 at 0:30
add a comment |
And on Windows:
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec mp3 "%~nG.mp3"
12
if you run this command in a batch (.bat) file you need to double the % signs => %%
– hB0
May 17 '15 at 14:24
Any idea how to run this command but copy to a new file that includes the original file's metadata?
– Barryman9000
Feb 26 '16 at 17:53
@Barryman9000 this was a long time ago but I think there's an output file option you could pass
– lxs
Mar 21 '16 at 15:00
@lxs thanks for the follow up. I ended up doing it with Powershell by changing the new file's name to be the original file's date created stackoverflow.com/a/35671099/197472
– Barryman9000
Mar 21 '16 at 23:08
Used it for removing metadata. But it is giving me Access denied error. So I changed output file name with an extra space to make it new file.FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata -1 -c:v copy -c:a copy "%~nG .mp3"
– Junaid
May 17 '17 at 7:27
|
show 2 more comments
A one-line bash script would be easy to do - replace *.avi
with your filetype:
for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
4
There should not be quotes around "*.avi", that makes bash think it's a string not a list of files
– JZL003
Jun 18 '15 at 1:57
whops. Thanks @JZL003!
– yolk
Nov 17 '15 at 19:49
The default encoder for .mov is libx264 (if available), but this encoder ignores-qscale
. Remove it and use the default settings, or use-crf
instead (default is-crf 23
).
– llogan
Aug 14 '16 at 19:29
4
This answer is better than the marked one.
– Hal
Aug 28 '17 at 8:57
1
If there are any spaces in the file name the command will fail because the backtickedbasename
subshell isn't quoted. This is exactly why bash has shell expansion instead: for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
– Calimo
Feb 16 '18 at 12:28
|
show 1 more comment
To convert with subdirectories use e.g.
find . -exec ffmpeg -i {} {}.mp3 ;
I used this, combined with this answer to convert VTT to SRT, to great effect.find -name "*.vtt" -exec ffmpeg -i {} {}.srt ;
– grooveplex
Jun 7 '18 at 19:40
I this command, with slight modif to convert all mp4 to mp3:find *.mp4 -exec ffmpeg -i {} {}.mp3 ;
– swdev
Jun 15 '18 at 23:28
Or, if you want to convert multiple file types:find . -name *.ogg -or -name *.wma -exec ffmpeg -i {} {}.mp3 ;
– bonh
Sep 26 '18 at 18:36
add a comment |
For anyone who wants to batch convert anything with ffmpeg but would like to have a convenient Windows interface, I developed this front-end:
https://sourceforge.net/projects/ffmpeg-batch
It adds to ffmpeg a window fashion interface, progress bars and time remaining info, features I always missed when using ffmpeg.
Ok this is a nice project! I have been chasing my tail for an hour trying to get ffmpeg to accept a relative outfile path in Windows and this makes it feel like cheating. EDIT: i used this to convert .xwm to .flac
– semtex41
2 days ago
add a comment |
If you want a graphical interface to batch process with ffmpegX, try Quick Batcher. It's free and will take your last ffmpegX settings to convert files you drop into it.
Note that you can't drag-drop folders onto Quick Batcher. So select files and then put them through Quick Batcher.
1
The "Quick Batcher" software is ONLY for MAC OS
– Mohammad ElNesr
Nov 1 '17 at 14:20
add a comment |
for i in *.flac;
do name=`echo "${i%.*}"`;
echo $name;
ffmpeg -i "${i}" -ab 320k -map_metadata 0 -id3v2_version 3 "${name}".mp3;
done
Batch process flac
files into mp3
(safe for file names with spaces) using [1] [2]
add a comment |
If you have GNU parallel you could convert all .avi files below vid_dir
to mp4 in parallel, using all except one of your CPU cores with
find vid_dir -type f -name '*.avi' -not -empty -print0 |
parallel -0 -j -1 ffmpeg -loglevel fatal -i {} {.}.mp4
To convert from/to different formats, change '*.avi'
or .mp4
as needed. GNU parallel is listed in most Linux distributions' repositories in a package which is usually called parallel
.
add a comment |
I know this might be redundant but I use this script to batch convert files.
old_extension=$1
new_extension=$2
for i in *."$old_extension";
do ffmpeg -i "$i" "${i%.*}.$new_extension";
done
It takes 2 arguments to make it more flexible :
- the extension you want to convert from
- the new extension you want to convert to
I create an alias for it but you can also use it manually like this:
sh batch_convert.sh mkv mp4
This would convert all the mkv
files into mp4
files.
As you can see it slightly more versatile. As long as ffmpeg
can convert it you can specify any two extensions.
Thats the best 👍
– Andreas Prang
Sep 29 '18 at 10:29
add a comment |
Another simple solution that hasn't been suggested yet would be to use xargs
:
ls *.avi | xargs -i -n1 ffmpeg -i {} "{}.mp4"
One minor pitfall is the awkward naming of output files (e.g. input.avi.mp4
). A possible workaround for this might be:
ls *.avi | xargs -i -n1 bash -c "i={}; ffmpeg -i {} "${i%.*}.mp4"
"
shellcheck.net has a few suggestions regarding your examples.
– llogan
Nov 27 '18 at 18:59
add a comment |
little php script to do it:
#!/usr/bin/env php
<?php
declare(strict_types = 1);
if ($argc !== 2) {
fprintf ( STDERR, "usage: %s dirn", $argv [0] );
die ( 1 );
}
$dir = rtrim ( $argv [1], DIRECTORY_SEPARATOR );
if (! is_readable ( $dir )) {
fprintf ( STDERR, "supplied path is not readable! (try running as an administrator?)" );
die(1);
}
if (! is_dir ( $dir )) {
fprintf ( STDERR, "supplied path is not a directory!" );
die(1);
}
$files = glob ( $dir . DIRECTORY_SEPARATOR . '*.avi' );
foreach ( $files as $file ) {
system ( "ffmpeg -i " . escapeshellarg ( $file ) . ' ' . escapeshellarg ( $file . '.mp4' ) );
}
1
A very limited scope answer as a user has to have PHP installed on their machine. The command line and batch file answers are much easier, and much less complex.
– ProfK
Nov 10 '17 at 9:06
2
@ProfK PHP is 1 of the most popular languages on SO - second, Isaac's answer for sh is somewhat unreliable, in that it might rename your files to something else than the original, for example, it doesn't preserve newlines in the filename. lyx's bat script is even worse, it COMPLETELY IGNORES any file with newlines in the name. not sure why, not even a syntax error or anything, but it does (tested on win10). my php script has neither problems, thanks toescapeshellarg()
, and works both on windows and linux. i agree its a edge-case though.
– hanshenrik
Nov 12 '17 at 12:43
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f5784661%2fhow-do-you-convert-an-entire-directory-with-ffmpeg%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
12 Answers
12
active
oldest
votes
12 Answers
12
active
oldest
votes
active
oldest
votes
active
oldest
votes
Previous answer will only create 1 output file called out.mov. To make a separate output file for each old movie, try this.
for i in *.avi;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" "${name}.mov";
done
19
If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov";
– Pif
Dec 17 '12 at 22:36
5
I'm getting the errori was unexpected at this time.
– Keavon
May 17 '14 at 1:09
4
do name=`echo "${i%.*}"`;
will work on file names with dots (and spaces) in them.
– Nepoxx
Jun 30 '15 at 14:50
4
Wow, this answer is incredibly overcomplicated. See one of the one-line answers.
– foobarbecue
Jun 11 '16 at 18:49
is this support for.bat
in windows?
– Jazuly
Jun 30 '18 at 6:12
|
show 2 more comments
Previous answer will only create 1 output file called out.mov. To make a separate output file for each old movie, try this.
for i in *.avi;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" "${name}.mov";
done
19
If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov";
– Pif
Dec 17 '12 at 22:36
5
I'm getting the errori was unexpected at this time.
– Keavon
May 17 '14 at 1:09
4
do name=`echo "${i%.*}"`;
will work on file names with dots (and spaces) in them.
– Nepoxx
Jun 30 '15 at 14:50
4
Wow, this answer is incredibly overcomplicated. See one of the one-line answers.
– foobarbecue
Jun 11 '16 at 18:49
is this support for.bat
in windows?
– Jazuly
Jun 30 '18 at 6:12
|
show 2 more comments
Previous answer will only create 1 output file called out.mov. To make a separate output file for each old movie, try this.
for i in *.avi;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" "${name}.mov";
done
Previous answer will only create 1 output file called out.mov. To make a separate output file for each old movie, try this.
for i in *.avi;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" "${name}.mov";
done
edited Apr 6 '17 at 16:06


Jason Cemra
361312
361312
answered Nov 20 '11 at 8:35
Isaac
1,140187
1,140187
19
If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov";
– Pif
Dec 17 '12 at 22:36
5
I'm getting the errori was unexpected at this time.
– Keavon
May 17 '14 at 1:09
4
do name=`echo "${i%.*}"`;
will work on file names with dots (and spaces) in them.
– Nepoxx
Jun 30 '15 at 14:50
4
Wow, this answer is incredibly overcomplicated. See one of the one-line answers.
– foobarbecue
Jun 11 '16 at 18:49
is this support for.bat
in windows?
– Jazuly
Jun 30 '18 at 6:12
|
show 2 more comments
19
If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov";
– Pif
Dec 17 '12 at 22:36
5
I'm getting the errori was unexpected at this time.
– Keavon
May 17 '14 at 1:09
4
do name=`echo "${i%.*}"`;
will work on file names with dots (and spaces) in them.
– Nepoxx
Jun 30 '15 at 14:50
4
Wow, this answer is incredibly overcomplicated. See one of the one-line answers.
– foobarbecue
Jun 11 '16 at 18:49
is this support for.bat
in windows?
– Jazuly
Jun 30 '18 at 6:12
19
19
If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov";
– Pif
Dec 17 '12 at 22:36
If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov";
– Pif
Dec 17 '12 at 22:36
5
5
I'm getting the error
i was unexpected at this time.
– Keavon
May 17 '14 at 1:09
I'm getting the error
i was unexpected at this time.
– Keavon
May 17 '14 at 1:09
4
4
do name=`echo "${i%.*}"`;
will work on file names with dots (and spaces) in them.– Nepoxx
Jun 30 '15 at 14:50
do name=`echo "${i%.*}"`;
will work on file names with dots (and spaces) in them.– Nepoxx
Jun 30 '15 at 14:50
4
4
Wow, this answer is incredibly overcomplicated. See one of the one-line answers.
– foobarbecue
Jun 11 '16 at 18:49
Wow, this answer is incredibly overcomplicated. See one of the one-line answers.
– foobarbecue
Jun 11 '16 at 18:49
is this support for
.bat
in windows?– Jazuly
Jun 30 '18 at 6:12
is this support for
.bat
in windows?– Jazuly
Jun 30 '18 at 6:12
|
show 2 more comments
For Linux and macOS this can be done in one line, using parameter expansion to change the filename extension of the output file:
for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done
This is perfect, thank you! Here's full command that ended up working great for me: for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
– Phil Kulak
Apr 28 '17 at 3:29
I am gettingi was unexpected at this time.
error in cmd, windows 10. I used following line:for i in *.mp3; do ffmpeg -i "$i" -map_metadata -1 -c:v copy -c:a copy "${i%.mp3}.mp3"; done
– Junaid
May 17 '17 at 7:13
1
@Junaid 1) Make sure to use a different name for the output file than the input, or output to another directory, becauseffmpeg
can't input and output to the same file. 2) I'm not sure if Bash commands work on Windows 10 natively. Maybe I should add to the answer that it is targeted towards systems that can natively use Bash such as Linux and macOS. lxs provided an Windows answer for this question.
– llogan
May 17 '17 at 17:25
I suggest this is marked as the correct answer.
– Alexandr Kurilin
Apr 25 '18 at 0:30
add a comment |
For Linux and macOS this can be done in one line, using parameter expansion to change the filename extension of the output file:
for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done
This is perfect, thank you! Here's full command that ended up working great for me: for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
– Phil Kulak
Apr 28 '17 at 3:29
I am gettingi was unexpected at this time.
error in cmd, windows 10. I used following line:for i in *.mp3; do ffmpeg -i "$i" -map_metadata -1 -c:v copy -c:a copy "${i%.mp3}.mp3"; done
– Junaid
May 17 '17 at 7:13
1
@Junaid 1) Make sure to use a different name for the output file than the input, or output to another directory, becauseffmpeg
can't input and output to the same file. 2) I'm not sure if Bash commands work on Windows 10 natively. Maybe I should add to the answer that it is targeted towards systems that can natively use Bash such as Linux and macOS. lxs provided an Windows answer for this question.
– llogan
May 17 '17 at 17:25
I suggest this is marked as the correct answer.
– Alexandr Kurilin
Apr 25 '18 at 0:30
add a comment |
For Linux and macOS this can be done in one line, using parameter expansion to change the filename extension of the output file:
for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done
For Linux and macOS this can be done in one line, using parameter expansion to change the filename extension of the output file:
for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done
edited Nov 5 '18 at 4:38


Boris
1,0871327
1,0871327
answered Nov 17 '15 at 20:15


llogan
43.8k13104134
43.8k13104134
This is perfect, thank you! Here's full command that ended up working great for me: for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
– Phil Kulak
Apr 28 '17 at 3:29
I am gettingi was unexpected at this time.
error in cmd, windows 10. I used following line:for i in *.mp3; do ffmpeg -i "$i" -map_metadata -1 -c:v copy -c:a copy "${i%.mp3}.mp3"; done
– Junaid
May 17 '17 at 7:13
1
@Junaid 1) Make sure to use a different name for the output file than the input, or output to another directory, becauseffmpeg
can't input and output to the same file. 2) I'm not sure if Bash commands work on Windows 10 natively. Maybe I should add to the answer that it is targeted towards systems that can natively use Bash such as Linux and macOS. lxs provided an Windows answer for this question.
– llogan
May 17 '17 at 17:25
I suggest this is marked as the correct answer.
– Alexandr Kurilin
Apr 25 '18 at 0:30
add a comment |
This is perfect, thank you! Here's full command that ended up working great for me: for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
– Phil Kulak
Apr 28 '17 at 3:29
I am gettingi was unexpected at this time.
error in cmd, windows 10. I used following line:for i in *.mp3; do ffmpeg -i "$i" -map_metadata -1 -c:v copy -c:a copy "${i%.mp3}.mp3"; done
– Junaid
May 17 '17 at 7:13
1
@Junaid 1) Make sure to use a different name for the output file than the input, or output to another directory, becauseffmpeg
can't input and output to the same file. 2) I'm not sure if Bash commands work on Windows 10 natively. Maybe I should add to the answer that it is targeted towards systems that can natively use Bash such as Linux and macOS. lxs provided an Windows answer for this question.
– llogan
May 17 '17 at 17:25
I suggest this is marked as the correct answer.
– Alexandr Kurilin
Apr 25 '18 at 0:30
This is perfect, thank you! Here's full command that ended up working great for me: for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
– Phil Kulak
Apr 28 '17 at 3:29
This is perfect, thank you! Here's full command that ended up working great for me: for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
– Phil Kulak
Apr 28 '17 at 3:29
I am getting
i was unexpected at this time.
error in cmd, windows 10. I used following line: for i in *.mp3; do ffmpeg -i "$i" -map_metadata -1 -c:v copy -c:a copy "${i%.mp3}.mp3"; done
– Junaid
May 17 '17 at 7:13
I am getting
i was unexpected at this time.
error in cmd, windows 10. I used following line: for i in *.mp3; do ffmpeg -i "$i" -map_metadata -1 -c:v copy -c:a copy "${i%.mp3}.mp3"; done
– Junaid
May 17 '17 at 7:13
1
1
@Junaid 1) Make sure to use a different name for the output file than the input, or output to another directory, because
ffmpeg
can't input and output to the same file. 2) I'm not sure if Bash commands work on Windows 10 natively. Maybe I should add to the answer that it is targeted towards systems that can natively use Bash such as Linux and macOS. lxs provided an Windows answer for this question.– llogan
May 17 '17 at 17:25
@Junaid 1) Make sure to use a different name for the output file than the input, or output to another directory, because
ffmpeg
can't input and output to the same file. 2) I'm not sure if Bash commands work on Windows 10 natively. Maybe I should add to the answer that it is targeted towards systems that can natively use Bash such as Linux and macOS. lxs provided an Windows answer for this question.– llogan
May 17 '17 at 17:25
I suggest this is marked as the correct answer.
– Alexandr Kurilin
Apr 25 '18 at 0:30
I suggest this is marked as the correct answer.
– Alexandr Kurilin
Apr 25 '18 at 0:30
add a comment |
And on Windows:
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec mp3 "%~nG.mp3"
12
if you run this command in a batch (.bat) file you need to double the % signs => %%
– hB0
May 17 '15 at 14:24
Any idea how to run this command but copy to a new file that includes the original file's metadata?
– Barryman9000
Feb 26 '16 at 17:53
@Barryman9000 this was a long time ago but I think there's an output file option you could pass
– lxs
Mar 21 '16 at 15:00
@lxs thanks for the follow up. I ended up doing it with Powershell by changing the new file's name to be the original file's date created stackoverflow.com/a/35671099/197472
– Barryman9000
Mar 21 '16 at 23:08
Used it for removing metadata. But it is giving me Access denied error. So I changed output file name with an extra space to make it new file.FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata -1 -c:v copy -c:a copy "%~nG .mp3"
– Junaid
May 17 '17 at 7:27
|
show 2 more comments
And on Windows:
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec mp3 "%~nG.mp3"
12
if you run this command in a batch (.bat) file you need to double the % signs => %%
– hB0
May 17 '15 at 14:24
Any idea how to run this command but copy to a new file that includes the original file's metadata?
– Barryman9000
Feb 26 '16 at 17:53
@Barryman9000 this was a long time ago but I think there's an output file option you could pass
– lxs
Mar 21 '16 at 15:00
@lxs thanks for the follow up. I ended up doing it with Powershell by changing the new file's name to be the original file's date created stackoverflow.com/a/35671099/197472
– Barryman9000
Mar 21 '16 at 23:08
Used it for removing metadata. But it is giving me Access denied error. So I changed output file name with an extra space to make it new file.FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata -1 -c:v copy -c:a copy "%~nG .mp3"
– Junaid
May 17 '17 at 7:27
|
show 2 more comments
And on Windows:
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec mp3 "%~nG.mp3"
And on Windows:
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec mp3 "%~nG.mp3"
answered Jun 17 '14 at 21:34
lxs
2,80711217
2,80711217
12
if you run this command in a batch (.bat) file you need to double the % signs => %%
– hB0
May 17 '15 at 14:24
Any idea how to run this command but copy to a new file that includes the original file's metadata?
– Barryman9000
Feb 26 '16 at 17:53
@Barryman9000 this was a long time ago but I think there's an output file option you could pass
– lxs
Mar 21 '16 at 15:00
@lxs thanks for the follow up. I ended up doing it with Powershell by changing the new file's name to be the original file's date created stackoverflow.com/a/35671099/197472
– Barryman9000
Mar 21 '16 at 23:08
Used it for removing metadata. But it is giving me Access denied error. So I changed output file name with an extra space to make it new file.FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata -1 -c:v copy -c:a copy "%~nG .mp3"
– Junaid
May 17 '17 at 7:27
|
show 2 more comments
12
if you run this command in a batch (.bat) file you need to double the % signs => %%
– hB0
May 17 '15 at 14:24
Any idea how to run this command but copy to a new file that includes the original file's metadata?
– Barryman9000
Feb 26 '16 at 17:53
@Barryman9000 this was a long time ago but I think there's an output file option you could pass
– lxs
Mar 21 '16 at 15:00
@lxs thanks for the follow up. I ended up doing it with Powershell by changing the new file's name to be the original file's date created stackoverflow.com/a/35671099/197472
– Barryman9000
Mar 21 '16 at 23:08
Used it for removing metadata. But it is giving me Access denied error. So I changed output file name with an extra space to make it new file.FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata -1 -c:v copy -c:a copy "%~nG .mp3"
– Junaid
May 17 '17 at 7:27
12
12
if you run this command in a batch (.bat) file you need to double the % signs => %%
– hB0
May 17 '15 at 14:24
if you run this command in a batch (.bat) file you need to double the % signs => %%
– hB0
May 17 '15 at 14:24
Any idea how to run this command but copy to a new file that includes the original file's metadata?
– Barryman9000
Feb 26 '16 at 17:53
Any idea how to run this command but copy to a new file that includes the original file's metadata?
– Barryman9000
Feb 26 '16 at 17:53
@Barryman9000 this was a long time ago but I think there's an output file option you could pass
– lxs
Mar 21 '16 at 15:00
@Barryman9000 this was a long time ago but I think there's an output file option you could pass
– lxs
Mar 21 '16 at 15:00
@lxs thanks for the follow up. I ended up doing it with Powershell by changing the new file's name to be the original file's date created stackoverflow.com/a/35671099/197472
– Barryman9000
Mar 21 '16 at 23:08
@lxs thanks for the follow up. I ended up doing it with Powershell by changing the new file's name to be the original file's date created stackoverflow.com/a/35671099/197472
– Barryman9000
Mar 21 '16 at 23:08
Used it for removing metadata. But it is giving me Access denied error. So I changed output file name with an extra space to make it new file.
FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata -1 -c:v copy -c:a copy "%~nG .mp3"
– Junaid
May 17 '17 at 7:27
Used it for removing metadata. But it is giving me Access denied error. So I changed output file name with an extra space to make it new file.
FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata -1 -c:v copy -c:a copy "%~nG .mp3"
– Junaid
May 17 '17 at 7:27
|
show 2 more comments
A one-line bash script would be easy to do - replace *.avi
with your filetype:
for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
4
There should not be quotes around "*.avi", that makes bash think it's a string not a list of files
– JZL003
Jun 18 '15 at 1:57
whops. Thanks @JZL003!
– yolk
Nov 17 '15 at 19:49
The default encoder for .mov is libx264 (if available), but this encoder ignores-qscale
. Remove it and use the default settings, or use-crf
instead (default is-crf 23
).
– llogan
Aug 14 '16 at 19:29
4
This answer is better than the marked one.
– Hal
Aug 28 '17 at 8:57
1
If there are any spaces in the file name the command will fail because the backtickedbasename
subshell isn't quoted. This is exactly why bash has shell expansion instead: for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
– Calimo
Feb 16 '18 at 12:28
|
show 1 more comment
A one-line bash script would be easy to do - replace *.avi
with your filetype:
for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
4
There should not be quotes around "*.avi", that makes bash think it's a string not a list of files
– JZL003
Jun 18 '15 at 1:57
whops. Thanks @JZL003!
– yolk
Nov 17 '15 at 19:49
The default encoder for .mov is libx264 (if available), but this encoder ignores-qscale
. Remove it and use the default settings, or use-crf
instead (default is-crf 23
).
– llogan
Aug 14 '16 at 19:29
4
This answer is better than the marked one.
– Hal
Aug 28 '17 at 8:57
1
If there are any spaces in the file name the command will fail because the backtickedbasename
subshell isn't quoted. This is exactly why bash has shell expansion instead: for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
– Calimo
Feb 16 '18 at 12:28
|
show 1 more comment
A one-line bash script would be easy to do - replace *.avi
with your filetype:
for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
A one-line bash script would be easy to do - replace *.avi
with your filetype:
for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
edited May 8 '18 at 22:59
answered Jul 2 '11 at 22:29
yolk
484410
484410
4
There should not be quotes around "*.avi", that makes bash think it's a string not a list of files
– JZL003
Jun 18 '15 at 1:57
whops. Thanks @JZL003!
– yolk
Nov 17 '15 at 19:49
The default encoder for .mov is libx264 (if available), but this encoder ignores-qscale
. Remove it and use the default settings, or use-crf
instead (default is-crf 23
).
– llogan
Aug 14 '16 at 19:29
4
This answer is better than the marked one.
– Hal
Aug 28 '17 at 8:57
1
If there are any spaces in the file name the command will fail because the backtickedbasename
subshell isn't quoted. This is exactly why bash has shell expansion instead: for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
– Calimo
Feb 16 '18 at 12:28
|
show 1 more comment
4
There should not be quotes around "*.avi", that makes bash think it's a string not a list of files
– JZL003
Jun 18 '15 at 1:57
whops. Thanks @JZL003!
– yolk
Nov 17 '15 at 19:49
The default encoder for .mov is libx264 (if available), but this encoder ignores-qscale
. Remove it and use the default settings, or use-crf
instead (default is-crf 23
).
– llogan
Aug 14 '16 at 19:29
4
This answer is better than the marked one.
– Hal
Aug 28 '17 at 8:57
1
If there are any spaces in the file name the command will fail because the backtickedbasename
subshell isn't quoted. This is exactly why bash has shell expansion instead: for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done
– Calimo
Feb 16 '18 at 12:28
4
4
There should not be quotes around "*.avi", that makes bash think it's a string not a list of files
– JZL003
Jun 18 '15 at 1:57
There should not be quotes around "*.avi", that makes bash think it's a string not a list of files
– JZL003
Jun 18 '15 at 1:57
whops. Thanks @JZL003!
– yolk
Nov 17 '15 at 19:49
whops. Thanks @JZL003!
– yolk
Nov 17 '15 at 19:49
The default encoder for .mov is libx264 (if available), but this encoder ignores
-qscale
. Remove it and use the default settings, or use -crf
instead (default is -crf 23
).– llogan
Aug 14 '16 at 19:29
The default encoder for .mov is libx264 (if available), but this encoder ignores
-qscale
. Remove it and use the default settings, or use -crf
instead (default is -crf 23
).– llogan
Aug 14 '16 at 19:29
4
4
This answer is better than the marked one.
– Hal
Aug 28 '17 at 8:57
This answer is better than the marked one.
– Hal
Aug 28 '17 at 8:57
1
1
If there are any spaces in the file name the command will fail because the backticked
basename
subshell isn't quoted. This is exactly why bash has shell expansion instead: for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done– Calimo
Feb 16 '18 at 12:28
If there are any spaces in the file name the command will fail because the backticked
basename
subshell isn't quoted. This is exactly why bash has shell expansion instead: for i in *.avi; do ffmpeg -i "$i" -qscale 0 "$(basename "$i" .avi)".mov ; done– Calimo
Feb 16 '18 at 12:28
|
show 1 more comment
To convert with subdirectories use e.g.
find . -exec ffmpeg -i {} {}.mp3 ;
I used this, combined with this answer to convert VTT to SRT, to great effect.find -name "*.vtt" -exec ffmpeg -i {} {}.srt ;
– grooveplex
Jun 7 '18 at 19:40
I this command, with slight modif to convert all mp4 to mp3:find *.mp4 -exec ffmpeg -i {} {}.mp3 ;
– swdev
Jun 15 '18 at 23:28
Or, if you want to convert multiple file types:find . -name *.ogg -or -name *.wma -exec ffmpeg -i {} {}.mp3 ;
– bonh
Sep 26 '18 at 18:36
add a comment |
To convert with subdirectories use e.g.
find . -exec ffmpeg -i {} {}.mp3 ;
I used this, combined with this answer to convert VTT to SRT, to great effect.find -name "*.vtt" -exec ffmpeg -i {} {}.srt ;
– grooveplex
Jun 7 '18 at 19:40
I this command, with slight modif to convert all mp4 to mp3:find *.mp4 -exec ffmpeg -i {} {}.mp3 ;
– swdev
Jun 15 '18 at 23:28
Or, if you want to convert multiple file types:find . -name *.ogg -or -name *.wma -exec ffmpeg -i {} {}.mp3 ;
– bonh
Sep 26 '18 at 18:36
add a comment |
To convert with subdirectories use e.g.
find . -exec ffmpeg -i {} {}.mp3 ;
To convert with subdirectories use e.g.
find . -exec ffmpeg -i {} {}.mp3 ;
answered Dec 12 '16 at 16:59
user2707001
663712
663712
I used this, combined with this answer to convert VTT to SRT, to great effect.find -name "*.vtt" -exec ffmpeg -i {} {}.srt ;
– grooveplex
Jun 7 '18 at 19:40
I this command, with slight modif to convert all mp4 to mp3:find *.mp4 -exec ffmpeg -i {} {}.mp3 ;
– swdev
Jun 15 '18 at 23:28
Or, if you want to convert multiple file types:find . -name *.ogg -or -name *.wma -exec ffmpeg -i {} {}.mp3 ;
– bonh
Sep 26 '18 at 18:36
add a comment |
I used this, combined with this answer to convert VTT to SRT, to great effect.find -name "*.vtt" -exec ffmpeg -i {} {}.srt ;
– grooveplex
Jun 7 '18 at 19:40
I this command, with slight modif to convert all mp4 to mp3:find *.mp4 -exec ffmpeg -i {} {}.mp3 ;
– swdev
Jun 15 '18 at 23:28
Or, if you want to convert multiple file types:find . -name *.ogg -or -name *.wma -exec ffmpeg -i {} {}.mp3 ;
– bonh
Sep 26 '18 at 18:36
I used this, combined with this answer to convert VTT to SRT, to great effect.
find -name "*.vtt" -exec ffmpeg -i {} {}.srt ;
– grooveplex
Jun 7 '18 at 19:40
I used this, combined with this answer to convert VTT to SRT, to great effect.
find -name "*.vtt" -exec ffmpeg -i {} {}.srt ;
– grooveplex
Jun 7 '18 at 19:40
I this command, with slight modif to convert all mp4 to mp3:
find *.mp4 -exec ffmpeg -i {} {}.mp3 ;
– swdev
Jun 15 '18 at 23:28
I this command, with slight modif to convert all mp4 to mp3:
find *.mp4 -exec ffmpeg -i {} {}.mp3 ;
– swdev
Jun 15 '18 at 23:28
Or, if you want to convert multiple file types:
find . -name *.ogg -or -name *.wma -exec ffmpeg -i {} {}.mp3 ;
– bonh
Sep 26 '18 at 18:36
Or, if you want to convert multiple file types:
find . -name *.ogg -or -name *.wma -exec ffmpeg -i {} {}.mp3 ;
– bonh
Sep 26 '18 at 18:36
add a comment |
For anyone who wants to batch convert anything with ffmpeg but would like to have a convenient Windows interface, I developed this front-end:
https://sourceforge.net/projects/ffmpeg-batch
It adds to ffmpeg a window fashion interface, progress bars and time remaining info, features I always missed when using ffmpeg.
Ok this is a nice project! I have been chasing my tail for an hour trying to get ffmpeg to accept a relative outfile path in Windows and this makes it feel like cheating. EDIT: i used this to convert .xwm to .flac
– semtex41
2 days ago
add a comment |
For anyone who wants to batch convert anything with ffmpeg but would like to have a convenient Windows interface, I developed this front-end:
https://sourceforge.net/projects/ffmpeg-batch
It adds to ffmpeg a window fashion interface, progress bars and time remaining info, features I always missed when using ffmpeg.
Ok this is a nice project! I have been chasing my tail for an hour trying to get ffmpeg to accept a relative outfile path in Windows and this makes it feel like cheating. EDIT: i used this to convert .xwm to .flac
– semtex41
2 days ago
add a comment |
For anyone who wants to batch convert anything with ffmpeg but would like to have a convenient Windows interface, I developed this front-end:
https://sourceforge.net/projects/ffmpeg-batch
It adds to ffmpeg a window fashion interface, progress bars and time remaining info, features I always missed when using ffmpeg.
For anyone who wants to batch convert anything with ffmpeg but would like to have a convenient Windows interface, I developed this front-end:
https://sourceforge.net/projects/ffmpeg-batch
It adds to ffmpeg a window fashion interface, progress bars and time remaining info, features I always missed when using ffmpeg.
answered Apr 25 '18 at 9:34
Eibel
5111
5111
Ok this is a nice project! I have been chasing my tail for an hour trying to get ffmpeg to accept a relative outfile path in Windows and this makes it feel like cheating. EDIT: i used this to convert .xwm to .flac
– semtex41
2 days ago
add a comment |
Ok this is a nice project! I have been chasing my tail for an hour trying to get ffmpeg to accept a relative outfile path in Windows and this makes it feel like cheating. EDIT: i used this to convert .xwm to .flac
– semtex41
2 days ago
Ok this is a nice project! I have been chasing my tail for an hour trying to get ffmpeg to accept a relative outfile path in Windows and this makes it feel like cheating. EDIT: i used this to convert .xwm to .flac
– semtex41
2 days ago
Ok this is a nice project! I have been chasing my tail for an hour trying to get ffmpeg to accept a relative outfile path in Windows and this makes it feel like cheating. EDIT: i used this to convert .xwm to .flac
– semtex41
2 days ago
add a comment |
If you want a graphical interface to batch process with ffmpegX, try Quick Batcher. It's free and will take your last ffmpegX settings to convert files you drop into it.
Note that you can't drag-drop folders onto Quick Batcher. So select files and then put them through Quick Batcher.
1
The "Quick Batcher" software is ONLY for MAC OS
– Mohammad ElNesr
Nov 1 '17 at 14:20
add a comment |
If you want a graphical interface to batch process with ffmpegX, try Quick Batcher. It's free and will take your last ffmpegX settings to convert files you drop into it.
Note that you can't drag-drop folders onto Quick Batcher. So select files and then put them through Quick Batcher.
1
The "Quick Batcher" software is ONLY for MAC OS
– Mohammad ElNesr
Nov 1 '17 at 14:20
add a comment |
If you want a graphical interface to batch process with ffmpegX, try Quick Batcher. It's free and will take your last ffmpegX settings to convert files you drop into it.
Note that you can't drag-drop folders onto Quick Batcher. So select files and then put them through Quick Batcher.
If you want a graphical interface to batch process with ffmpegX, try Quick Batcher. It's free and will take your last ffmpegX settings to convert files you drop into it.
Note that you can't drag-drop folders onto Quick Batcher. So select files and then put them through Quick Batcher.
answered Apr 5 '14 at 8:58
Nirav Mehta
16913
16913
1
The "Quick Batcher" software is ONLY for MAC OS
– Mohammad ElNesr
Nov 1 '17 at 14:20
add a comment |
1
The "Quick Batcher" software is ONLY for MAC OS
– Mohammad ElNesr
Nov 1 '17 at 14:20
1
1
The "Quick Batcher" software is ONLY for MAC OS
– Mohammad ElNesr
Nov 1 '17 at 14:20
The "Quick Batcher" software is ONLY for MAC OS
– Mohammad ElNesr
Nov 1 '17 at 14:20
add a comment |
for i in *.flac;
do name=`echo "${i%.*}"`;
echo $name;
ffmpeg -i "${i}" -ab 320k -map_metadata 0 -id3v2_version 3 "${name}".mp3;
done
Batch process flac
files into mp3
(safe for file names with spaces) using [1] [2]
add a comment |
for i in *.flac;
do name=`echo "${i%.*}"`;
echo $name;
ffmpeg -i "${i}" -ab 320k -map_metadata 0 -id3v2_version 3 "${name}".mp3;
done
Batch process flac
files into mp3
(safe for file names with spaces) using [1] [2]
add a comment |
for i in *.flac;
do name=`echo "${i%.*}"`;
echo $name;
ffmpeg -i "${i}" -ab 320k -map_metadata 0 -id3v2_version 3 "${name}".mp3;
done
Batch process flac
files into mp3
(safe for file names with spaces) using [1] [2]
for i in *.flac;
do name=`echo "${i%.*}"`;
echo $name;
ffmpeg -i "${i}" -ab 320k -map_metadata 0 -id3v2_version 3 "${name}".mp3;
done
Batch process flac
files into mp3
(safe for file names with spaces) using [1] [2]
edited May 23 '17 at 12:10
Community♦
11
11
answered May 13 '16 at 2:15
César
93666
93666
add a comment |
add a comment |
If you have GNU parallel you could convert all .avi files below vid_dir
to mp4 in parallel, using all except one of your CPU cores with
find vid_dir -type f -name '*.avi' -not -empty -print0 |
parallel -0 -j -1 ffmpeg -loglevel fatal -i {} {.}.mp4
To convert from/to different formats, change '*.avi'
or .mp4
as needed. GNU parallel is listed in most Linux distributions' repositories in a package which is usually called parallel
.
add a comment |
If you have GNU parallel you could convert all .avi files below vid_dir
to mp4 in parallel, using all except one of your CPU cores with
find vid_dir -type f -name '*.avi' -not -empty -print0 |
parallel -0 -j -1 ffmpeg -loglevel fatal -i {} {.}.mp4
To convert from/to different formats, change '*.avi'
or .mp4
as needed. GNU parallel is listed in most Linux distributions' repositories in a package which is usually called parallel
.
add a comment |
If you have GNU parallel you could convert all .avi files below vid_dir
to mp4 in parallel, using all except one of your CPU cores with
find vid_dir -type f -name '*.avi' -not -empty -print0 |
parallel -0 -j -1 ffmpeg -loglevel fatal -i {} {.}.mp4
To convert from/to different formats, change '*.avi'
or .mp4
as needed. GNU parallel is listed in most Linux distributions' repositories in a package which is usually called parallel
.
If you have GNU parallel you could convert all .avi files below vid_dir
to mp4 in parallel, using all except one of your CPU cores with
find vid_dir -type f -name '*.avi' -not -empty -print0 |
parallel -0 -j -1 ffmpeg -loglevel fatal -i {} {.}.mp4
To convert from/to different formats, change '*.avi'
or .mp4
as needed. GNU parallel is listed in most Linux distributions' repositories in a package which is usually called parallel
.
answered May 10 '18 at 9:37


Sebastian Scheurer
312
312
add a comment |
add a comment |
I know this might be redundant but I use this script to batch convert files.
old_extension=$1
new_extension=$2
for i in *."$old_extension";
do ffmpeg -i "$i" "${i%.*}.$new_extension";
done
It takes 2 arguments to make it more flexible :
- the extension you want to convert from
- the new extension you want to convert to
I create an alias for it but you can also use it manually like this:
sh batch_convert.sh mkv mp4
This would convert all the mkv
files into mp4
files.
As you can see it slightly more versatile. As long as ffmpeg
can convert it you can specify any two extensions.
Thats the best 👍
– Andreas Prang
Sep 29 '18 at 10:29
add a comment |
I know this might be redundant but I use this script to batch convert files.
old_extension=$1
new_extension=$2
for i in *."$old_extension";
do ffmpeg -i "$i" "${i%.*}.$new_extension";
done
It takes 2 arguments to make it more flexible :
- the extension you want to convert from
- the new extension you want to convert to
I create an alias for it but you can also use it manually like this:
sh batch_convert.sh mkv mp4
This would convert all the mkv
files into mp4
files.
As you can see it slightly more versatile. As long as ffmpeg
can convert it you can specify any two extensions.
Thats the best 👍
– Andreas Prang
Sep 29 '18 at 10:29
add a comment |
I know this might be redundant but I use this script to batch convert files.
old_extension=$1
new_extension=$2
for i in *."$old_extension";
do ffmpeg -i "$i" "${i%.*}.$new_extension";
done
It takes 2 arguments to make it more flexible :
- the extension you want to convert from
- the new extension you want to convert to
I create an alias for it but you can also use it manually like this:
sh batch_convert.sh mkv mp4
This would convert all the mkv
files into mp4
files.
As you can see it slightly more versatile. As long as ffmpeg
can convert it you can specify any two extensions.
I know this might be redundant but I use this script to batch convert files.
old_extension=$1
new_extension=$2
for i in *."$old_extension";
do ffmpeg -i "$i" "${i%.*}.$new_extension";
done
It takes 2 arguments to make it more flexible :
- the extension you want to convert from
- the new extension you want to convert to
I create an alias for it but you can also use it manually like this:
sh batch_convert.sh mkv mp4
This would convert all the mkv
files into mp4
files.
As you can see it slightly more versatile. As long as ffmpeg
can convert it you can specify any two extensions.
edited Sep 15 '18 at 20:55
answered Sep 14 '18 at 20:17


Alexander Luna
2,30021430
2,30021430
Thats the best 👍
– Andreas Prang
Sep 29 '18 at 10:29
add a comment |
Thats the best 👍
– Andreas Prang
Sep 29 '18 at 10:29
Thats the best 👍
– Andreas Prang
Sep 29 '18 at 10:29
Thats the best 👍
– Andreas Prang
Sep 29 '18 at 10:29
add a comment |
Another simple solution that hasn't been suggested yet would be to use xargs
:
ls *.avi | xargs -i -n1 ffmpeg -i {} "{}.mp4"
One minor pitfall is the awkward naming of output files (e.g. input.avi.mp4
). A possible workaround for this might be:
ls *.avi | xargs -i -n1 bash -c "i={}; ffmpeg -i {} "${i%.*}.mp4"
"
shellcheck.net has a few suggestions regarding your examples.
– llogan
Nov 27 '18 at 18:59
add a comment |
Another simple solution that hasn't been suggested yet would be to use xargs
:
ls *.avi | xargs -i -n1 ffmpeg -i {} "{}.mp4"
One minor pitfall is the awkward naming of output files (e.g. input.avi.mp4
). A possible workaround for this might be:
ls *.avi | xargs -i -n1 bash -c "i={}; ffmpeg -i {} "${i%.*}.mp4"
"
shellcheck.net has a few suggestions regarding your examples.
– llogan
Nov 27 '18 at 18:59
add a comment |
Another simple solution that hasn't been suggested yet would be to use xargs
:
ls *.avi | xargs -i -n1 ffmpeg -i {} "{}.mp4"
One minor pitfall is the awkward naming of output files (e.g. input.avi.mp4
). A possible workaround for this might be:
ls *.avi | xargs -i -n1 bash -c "i={}; ffmpeg -i {} "${i%.*}.mp4"
"
Another simple solution that hasn't been suggested yet would be to use xargs
:
ls *.avi | xargs -i -n1 ffmpeg -i {} "{}.mp4"
One minor pitfall is the awkward naming of output files (e.g. input.avi.mp4
). A possible workaround for this might be:
ls *.avi | xargs -i -n1 bash -c "i={}; ffmpeg -i {} "${i%.*}.mp4"
"
answered Nov 27 '18 at 17:01
telenachos
708316
708316
shellcheck.net has a few suggestions regarding your examples.
– llogan
Nov 27 '18 at 18:59
add a comment |
shellcheck.net has a few suggestions regarding your examples.
– llogan
Nov 27 '18 at 18:59
shellcheck.net has a few suggestions regarding your examples.
– llogan
Nov 27 '18 at 18:59
shellcheck.net has a few suggestions regarding your examples.
– llogan
Nov 27 '18 at 18:59
add a comment |
little php script to do it:
#!/usr/bin/env php
<?php
declare(strict_types = 1);
if ($argc !== 2) {
fprintf ( STDERR, "usage: %s dirn", $argv [0] );
die ( 1 );
}
$dir = rtrim ( $argv [1], DIRECTORY_SEPARATOR );
if (! is_readable ( $dir )) {
fprintf ( STDERR, "supplied path is not readable! (try running as an administrator?)" );
die(1);
}
if (! is_dir ( $dir )) {
fprintf ( STDERR, "supplied path is not a directory!" );
die(1);
}
$files = glob ( $dir . DIRECTORY_SEPARATOR . '*.avi' );
foreach ( $files as $file ) {
system ( "ffmpeg -i " . escapeshellarg ( $file ) . ' ' . escapeshellarg ( $file . '.mp4' ) );
}
1
A very limited scope answer as a user has to have PHP installed on their machine. The command line and batch file answers are much easier, and much less complex.
– ProfK
Nov 10 '17 at 9:06
2
@ProfK PHP is 1 of the most popular languages on SO - second, Isaac's answer for sh is somewhat unreliable, in that it might rename your files to something else than the original, for example, it doesn't preserve newlines in the filename. lyx's bat script is even worse, it COMPLETELY IGNORES any file with newlines in the name. not sure why, not even a syntax error or anything, but it does (tested on win10). my php script has neither problems, thanks toescapeshellarg()
, and works both on windows and linux. i agree its a edge-case though.
– hanshenrik
Nov 12 '17 at 12:43
add a comment |
little php script to do it:
#!/usr/bin/env php
<?php
declare(strict_types = 1);
if ($argc !== 2) {
fprintf ( STDERR, "usage: %s dirn", $argv [0] );
die ( 1 );
}
$dir = rtrim ( $argv [1], DIRECTORY_SEPARATOR );
if (! is_readable ( $dir )) {
fprintf ( STDERR, "supplied path is not readable! (try running as an administrator?)" );
die(1);
}
if (! is_dir ( $dir )) {
fprintf ( STDERR, "supplied path is not a directory!" );
die(1);
}
$files = glob ( $dir . DIRECTORY_SEPARATOR . '*.avi' );
foreach ( $files as $file ) {
system ( "ffmpeg -i " . escapeshellarg ( $file ) . ' ' . escapeshellarg ( $file . '.mp4' ) );
}
1
A very limited scope answer as a user has to have PHP installed on their machine. The command line and batch file answers are much easier, and much less complex.
– ProfK
Nov 10 '17 at 9:06
2
@ProfK PHP is 1 of the most popular languages on SO - second, Isaac's answer for sh is somewhat unreliable, in that it might rename your files to something else than the original, for example, it doesn't preserve newlines in the filename. lyx's bat script is even worse, it COMPLETELY IGNORES any file with newlines in the name. not sure why, not even a syntax error or anything, but it does (tested on win10). my php script has neither problems, thanks toescapeshellarg()
, and works both on windows and linux. i agree its a edge-case though.
– hanshenrik
Nov 12 '17 at 12:43
add a comment |
little php script to do it:
#!/usr/bin/env php
<?php
declare(strict_types = 1);
if ($argc !== 2) {
fprintf ( STDERR, "usage: %s dirn", $argv [0] );
die ( 1 );
}
$dir = rtrim ( $argv [1], DIRECTORY_SEPARATOR );
if (! is_readable ( $dir )) {
fprintf ( STDERR, "supplied path is not readable! (try running as an administrator?)" );
die(1);
}
if (! is_dir ( $dir )) {
fprintf ( STDERR, "supplied path is not a directory!" );
die(1);
}
$files = glob ( $dir . DIRECTORY_SEPARATOR . '*.avi' );
foreach ( $files as $file ) {
system ( "ffmpeg -i " . escapeshellarg ( $file ) . ' ' . escapeshellarg ( $file . '.mp4' ) );
}
little php script to do it:
#!/usr/bin/env php
<?php
declare(strict_types = 1);
if ($argc !== 2) {
fprintf ( STDERR, "usage: %s dirn", $argv [0] );
die ( 1 );
}
$dir = rtrim ( $argv [1], DIRECTORY_SEPARATOR );
if (! is_readable ( $dir )) {
fprintf ( STDERR, "supplied path is not readable! (try running as an administrator?)" );
die(1);
}
if (! is_dir ( $dir )) {
fprintf ( STDERR, "supplied path is not a directory!" );
die(1);
}
$files = glob ( $dir . DIRECTORY_SEPARATOR . '*.avi' );
foreach ( $files as $file ) {
system ( "ffmpeg -i " . escapeshellarg ( $file ) . ' ' . escapeshellarg ( $file . '.mp4' ) );
}
answered Nov 7 '17 at 13:47
hanshenrik
9,59221738
9,59221738
1
A very limited scope answer as a user has to have PHP installed on their machine. The command line and batch file answers are much easier, and much less complex.
– ProfK
Nov 10 '17 at 9:06
2
@ProfK PHP is 1 of the most popular languages on SO - second, Isaac's answer for sh is somewhat unreliable, in that it might rename your files to something else than the original, for example, it doesn't preserve newlines in the filename. lyx's bat script is even worse, it COMPLETELY IGNORES any file with newlines in the name. not sure why, not even a syntax error or anything, but it does (tested on win10). my php script has neither problems, thanks toescapeshellarg()
, and works both on windows and linux. i agree its a edge-case though.
– hanshenrik
Nov 12 '17 at 12:43
add a comment |
1
A very limited scope answer as a user has to have PHP installed on their machine. The command line and batch file answers are much easier, and much less complex.
– ProfK
Nov 10 '17 at 9:06
2
@ProfK PHP is 1 of the most popular languages on SO - second, Isaac's answer for sh is somewhat unreliable, in that it might rename your files to something else than the original, for example, it doesn't preserve newlines in the filename. lyx's bat script is even worse, it COMPLETELY IGNORES any file with newlines in the name. not sure why, not even a syntax error or anything, but it does (tested on win10). my php script has neither problems, thanks toescapeshellarg()
, and works both on windows and linux. i agree its a edge-case though.
– hanshenrik
Nov 12 '17 at 12:43
1
1
A very limited scope answer as a user has to have PHP installed on their machine. The command line and batch file answers are much easier, and much less complex.
– ProfK
Nov 10 '17 at 9:06
A very limited scope answer as a user has to have PHP installed on their machine. The command line and batch file answers are much easier, and much less complex.
– ProfK
Nov 10 '17 at 9:06
2
2
@ProfK PHP is 1 of the most popular languages on SO - second, Isaac's answer for sh is somewhat unreliable, in that it might rename your files to something else than the original, for example, it doesn't preserve newlines in the filename. lyx's bat script is even worse, it COMPLETELY IGNORES any file with newlines in the name. not sure why, not even a syntax error or anything, but it does (tested on win10). my php script has neither problems, thanks to
escapeshellarg()
, and works both on windows and linux. i agree its a edge-case though.– hanshenrik
Nov 12 '17 at 12:43
@ProfK PHP is 1 of the most popular languages on SO - second, Isaac's answer for sh is somewhat unreliable, in that it might rename your files to something else than the original, for example, it doesn't preserve newlines in the filename. lyx's bat script is even worse, it COMPLETELY IGNORES any file with newlines in the name. not sure why, not even a syntax error or anything, but it does (tested on win10). my php script has neither problems, thanks to
escapeshellarg()
, and works both on windows and linux. i agree its a edge-case though.– hanshenrik
Nov 12 '17 at 12:43
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fstackoverflow.com%2fquestions%2f5784661%2fhow-do-you-convert-an-entire-directory-with-ffmpeg%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