Remove files if command not sucessful
I mux mp4 videos and webm videos with srt (subtitles) files. All the files have the same filenames but different extensions. Like this:
Video1.mp4
Video1.srt
or
Video2.webm
Video2.srt
Sometimes the muxing (merge video with subtitles) is not successful because the srt file is empty. The command line tool I use to merge video with subtitles is called MKVMerge and has 3 exit codes:
0 -- This exit codes means that muxing has completed successfully.
1 -- In this case mkvmerge(1) has output at least one warning, but muxing did continue. A warning is prefixed with the text 'Warning:'. Depending on the issues involved the resulting file might be ok or not. The user is urged to check both the warning and the resulting file.
2 -- This exit code is used after an error occurred. mkvmerge(1) aborts right after outputting the error message. Error messages range from wrong command line arguments over read/write errors to broken files.
I want a command to remove the SRT file if the error code is 1.
Here's what I'm using:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
)
I want that command line to remove the .srt file (which uses the same filename as mp4 or webm) if the error code is 1 (one).
windows command-line video batch
add a comment |
I mux mp4 videos and webm videos with srt (subtitles) files. All the files have the same filenames but different extensions. Like this:
Video1.mp4
Video1.srt
or
Video2.webm
Video2.srt
Sometimes the muxing (merge video with subtitles) is not successful because the srt file is empty. The command line tool I use to merge video with subtitles is called MKVMerge and has 3 exit codes:
0 -- This exit codes means that muxing has completed successfully.
1 -- In this case mkvmerge(1) has output at least one warning, but muxing did continue. A warning is prefixed with the text 'Warning:'. Depending on the issues involved the resulting file might be ok or not. The user is urged to check both the warning and the resulting file.
2 -- This exit code is used after an error occurred. mkvmerge(1) aborts right after outputting the error message. Error messages range from wrong command line arguments over read/write errors to broken files.
I want a command to remove the SRT file if the error code is 1.
Here's what I'm using:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
)
I want that command line to remove the .srt file (which uses the same filename as mp4 or webm) if the error code is 1 (one).
windows command-line video batch
Errorlevel - Windows CMD - SS64.com
– DavidPostill♦
Jan 7 at 20:08
I know about ERRORLEVEL, but I can only perform simple tasks. I don't know how to append when there's a lot of arguments.
– G. L.
Jan 7 at 20:14
add a comment |
I mux mp4 videos and webm videos with srt (subtitles) files. All the files have the same filenames but different extensions. Like this:
Video1.mp4
Video1.srt
or
Video2.webm
Video2.srt
Sometimes the muxing (merge video with subtitles) is not successful because the srt file is empty. The command line tool I use to merge video with subtitles is called MKVMerge and has 3 exit codes:
0 -- This exit codes means that muxing has completed successfully.
1 -- In this case mkvmerge(1) has output at least one warning, but muxing did continue. A warning is prefixed with the text 'Warning:'. Depending on the issues involved the resulting file might be ok or not. The user is urged to check both the warning and the resulting file.
2 -- This exit code is used after an error occurred. mkvmerge(1) aborts right after outputting the error message. Error messages range from wrong command line arguments over read/write errors to broken files.
I want a command to remove the SRT file if the error code is 1.
Here's what I'm using:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
)
I want that command line to remove the .srt file (which uses the same filename as mp4 or webm) if the error code is 1 (one).
windows command-line video batch
I mux mp4 videos and webm videos with srt (subtitles) files. All the files have the same filenames but different extensions. Like this:
Video1.mp4
Video1.srt
or
Video2.webm
Video2.srt
Sometimes the muxing (merge video with subtitles) is not successful because the srt file is empty. The command line tool I use to merge video with subtitles is called MKVMerge and has 3 exit codes:
0 -- This exit codes means that muxing has completed successfully.
1 -- In this case mkvmerge(1) has output at least one warning, but muxing did continue. A warning is prefixed with the text 'Warning:'. Depending on the issues involved the resulting file might be ok or not. The user is urged to check both the warning and the resulting file.
2 -- This exit code is used after an error occurred. mkvmerge(1) aborts right after outputting the error message. Error messages range from wrong command line arguments over read/write errors to broken files.
I want a command to remove the SRT file if the error code is 1.
Here's what I'm using:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
)
I want that command line to remove the .srt file (which uses the same filename as mp4 or webm) if the error code is 1 (one).
windows command-line video batch
windows command-line video batch
asked Jan 7 at 19:46
G. L.G. L.
7511
7511
Errorlevel - Windows CMD - SS64.com
– DavidPostill♦
Jan 7 at 20:08
I know about ERRORLEVEL, but I can only perform simple tasks. I don't know how to append when there's a lot of arguments.
– G. L.
Jan 7 at 20:14
add a comment |
Errorlevel - Windows CMD - SS64.com
– DavidPostill♦
Jan 7 at 20:08
I know about ERRORLEVEL, but I can only perform simple tasks. I don't know how to append when there's a lot of arguments.
– G. L.
Jan 7 at 20:14
Errorlevel - Windows CMD - SS64.com
– DavidPostill♦
Jan 7 at 20:08
Errorlevel - Windows CMD - SS64.com
– DavidPostill♦
Jan 7 at 20:08
I know about ERRORLEVEL, but I can only perform simple tasks. I don't know how to append when there's a lot of arguments.
– G. L.
Jan 7 at 20:14
I know about ERRORLEVEL, but I can only perform simple tasks. I don't know how to append when there's a lot of arguments.
– G. L.
Jan 7 at 20:14
add a comment |
1 Answer
1
active
oldest
votes
I want that command line to remove the .srt file if the error code is 1.
Look at the error level set by mkvmerge
.
Try the following batch file:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
if %errorlevel% equ 1 (
del /q "%%~nA.srt"
)
)
Further Reading
- An A-Z Index of the Windows CMD command line | SS64.com
- Windows CMD Commands (categorized) - Windows CMD - SS64.com
- Del - Delete Files - Windows CMD - SS64.com
- Errorlevel - Windows CMD - SS64.com
Thanks a lot. That's just what I wanted.
– G. L.
Jan 7 at 23:27
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1391631%2fremove-files-if-command-not-sucessful%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I want that command line to remove the .srt file if the error code is 1.
Look at the error level set by mkvmerge
.
Try the following batch file:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
if %errorlevel% equ 1 (
del /q "%%~nA.srt"
)
)
Further Reading
- An A-Z Index of the Windows CMD command line | SS64.com
- Windows CMD Commands (categorized) - Windows CMD - SS64.com
- Del - Delete Files - Windows CMD - SS64.com
- Errorlevel - Windows CMD - SS64.com
Thanks a lot. That's just what I wanted.
– G. L.
Jan 7 at 23:27
add a comment |
I want that command line to remove the .srt file if the error code is 1.
Look at the error level set by mkvmerge
.
Try the following batch file:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
if %errorlevel% equ 1 (
del /q "%%~nA.srt"
)
)
Further Reading
- An A-Z Index of the Windows CMD command line | SS64.com
- Windows CMD Commands (categorized) - Windows CMD - SS64.com
- Del - Delete Files - Windows CMD - SS64.com
- Errorlevel - Windows CMD - SS64.com
Thanks a lot. That's just what I wanted.
– G. L.
Jan 7 at 23:27
add a comment |
I want that command line to remove the .srt file if the error code is 1.
Look at the error level set by mkvmerge
.
Try the following batch file:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
if %errorlevel% equ 1 (
del /q "%%~nA.srt"
)
)
Further Reading
- An A-Z Index of the Windows CMD command line | SS64.com
- Windows CMD Commands (categorized) - Windows CMD - SS64.com
- Del - Delete Files - Windows CMD - SS64.com
- Errorlevel - Windows CMD - SS64.com
I want that command line to remove the .srt file if the error code is 1.
Look at the error level set by mkvmerge
.
Try the following batch file:
FOR /R "D:Folder" %%A IN (*.mp4 *.webm) do (
"D:mkvmerge.exe" -o "%%~nxA" "%%~A" --language 0:eng "%%~nA.srt"
if %errorlevel% equ 1 (
del /q "%%~nA.srt"
)
)
Further Reading
- An A-Z Index of the Windows CMD command line | SS64.com
- Windows CMD Commands (categorized) - Windows CMD - SS64.com
- Del - Delete Files - Windows CMD - SS64.com
- Errorlevel - Windows CMD - SS64.com
answered Jan 7 at 20:21
DavidPostill♦DavidPostill
105k25227262
105k25227262
Thanks a lot. That's just what I wanted.
– G. L.
Jan 7 at 23:27
add a comment |
Thanks a lot. That's just what I wanted.
– G. L.
Jan 7 at 23:27
Thanks a lot. That's just what I wanted.
– G. L.
Jan 7 at 23:27
Thanks a lot. That's just what I wanted.
– G. L.
Jan 7 at 23:27
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1391631%2fremove-files-if-command-not-sucessful%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
Errorlevel - Windows CMD - SS64.com
– DavidPostill♦
Jan 7 at 20:08
I know about ERRORLEVEL, but I can only perform simple tasks. I don't know how to append when there's a lot of arguments.
– G. L.
Jan 7 at 20:14