Hi
I hope someone can help me....
I need a script to copy a Folder of MKV Videos to MP4 Videos, with the same Video and Audio Copy, So its basically just changing all the Videos inside the folder from MKV to MP4, with unchanged Video Format and Audio Format quality.
Does anyone have a script for me to use please, or teach me how to do this?
Many Thanks
If you are not afraid of doing own research and thinking logically filling in missing bits of the solution, http://avidemux.org/smif/index.php?topic=17187.0 could give you pretty much everything needed to find your own.
Please be aware that the parameters of the Mp4 muxer have been extended since 2.7.0 release to allow to force display aspect ratio, mp4 container is generally much more restrictive than MKV WRT codecs so that conversion may easily fail.
In any case you are much better off using the latest Avidemux nightly instead of the outdated 2.7.0 release. Alternatively, use just ffmpeg directly (Avidemux adds no benefits in your use case).
Thanks
Will give it a try ;)
Quote from: eumagga0x2a on March 24, 2018, 05:06:32 PM
If you are not afraid of doing own research and thinking logically filling in missing bits of the solution, http://avidemux.org/smif/index.php?topic=17187.0 could give you pretty much everything needed to find your own.
Please be aware that the parameters of the Mp4 muxer have been extended since 2.7.0 release to allow to force display aspect ratio, mp4 container is generally much more restrictive than MKV WRT codecs so that conversion may easily fail.
In any case you are much better off using the latest Avidemux nightly instead of the outdated 2.7.0 release. Alternatively, use just ffmpeg directly (Avidemux adds no benefits in your use case).
Thanks got it all working BUT I get an error message, Which is below...
I have to select ok for every file loaded for it to do the conversion, The conversion works great, apart from having to select ok for every file loaded.
TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50
Here are my Bat file Settingsset avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
for %%f in (*.mkv) do %avidemux% --load "%%f" --run pui.py --save "%%~nf.mp4" --quit
Here are my Py file Settingsadm = Avidemux()
adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True", "forceAspectRatio=False", "aspectRatio=1")
Any idea what is wrong
Thanks
Basically it means that ADM_fopen fails, I'll try to look into it later today.
Thanks buddy
Quote from: eumagga0x2a on March 25, 2018, 11:07:44 AM
Basically it means that ADM_fopen fails, I'll try to look into it later today.
Would this be because of the current software version?
I don't think so. Why do you use the GUI version instead of the CLI one?
(The release is really not an option because you lose the last few frames of the video if it contains B-frames)
Could you please create a directory with just a single MKV video in it, run your batch and post admlog.txt resulting from this run if you get the same error?
Quote from: eumagga0x2a on March 25, 2018, 12:09:09 PM
Could you please create a directory with just a single MKV video in it, run your batch and post admlog.txt resulting from this run if you get the same error?
Where do I post admlog.txt?
If possible, compress it and attach it to your reply. If it doesn't work due to antispam measures, please send it by a personal message.
Quote from: eumagga0x2a on March 25, 2018, 12:43:25 PM
If possible, compress it and attach it to your reply. If it doesn't work due to antispam measures, please send it by a personal message.
The script is now running since I chance to CLI, BUT now with the input video MKV file size 1.30GB, when it converts to MP4 the finished file size is 32.6KB
I don't know how or where to get the admlog.txt
Thanks for helping me
You find it in %localappdata%\avidemux\
I'm sorry, could you please attach a ZIP compressed version? I don't have unrar on my smartphone.
ok one min
There you go
Thanks, the log shows that Avidemux crashed because no video had been loaded. The command line doesn't mention a --load option, subsequent call of --run for your project script leads as expected to a crash.
ok what am I doing wrong?
There are 3 MKV Videos inside the folder
Here are my Bat file Settings
set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
for %%f in (*.mkv) do %avidemux% --load "%%f" --run pui.py --save "%%~nf.mp4" --quit
Here are my Py file Settings
adm = Avidemux()
adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True", "forceAspectRatio=False", "aspectRatio=1")
Thanks
I'm not really familiar with Windows cmd.exe scripting. Does loading a file alone work? Leave out --run and --save commands for testing purposes and attach a new admlog.txt, please.
Not sure how to do that, I see no out --run and --save commands in the script
Quote from: jonwren on March 25, 2018, 02:38:39 PM
Here are my Bat file Settings
set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
for %%f in (*.mkv) do %avidemux% --load "%%f" --run pui.py --save "%%~nf.mp4" --quit
Leave the emboldened part of the command line out.
The program runs and then disappears and nothing has been done
I re-putin the --run pui.py --save "%%~nf.mp4" --quit command
and now am getting this error again
TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50
This is the py I just tried but same error
TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50
#PY <- Needed to identify #
#--automatically built--
#
# Load all the files in "c:\\tmp\\" with .mkv extension.
# That's it.
#
ext="mkv"
inputFolder="c:\\tmp\\"
#
def convert(filein):
if(0 == adm.loadVideo("C:\Users\jonwr\Desktop\New folder.mkv"):
ui.displayError("oops","cannot load "+filein)
raise
print("Done")
# ---------- Inserting project start------------
adm.videoCodec("Copy")
adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True", "forceAspectRatio=False", "aspectRatio=1")
# ---------- Inserting project end------------
adm.save(filein+".converted.mp4") # save the file
print("Done")
#
# Main
#
ui=Gui()
adm=Avidemux()
#
list=get_folder_content(inputFolder,ext)
if(list is None):
raise
for i in list:
convert(i)
print("Done")
Quote from: jonwren on March 25, 2018, 03:03:23 PM
The program runs and then disappears and nothing has been done
I need admlog.txt from that run.
Thanks, it is not from the run with the --load option alone, but it includes useful information. Will look into it.
Thank you
Could you please try out adding --nogui option before --run but after --load?
(This does not do what one might think. Instead, it prevents dialogs from popping up. The option would not fix the exception but might hide the unpleasant effects)
It has the same effect of error
TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50
Thanks, it doesn't suppress dialogs opened for errors then. Will try to find out what is going on later tonight.
Once it has done a scan this pops up
TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50
I have to select OK and then the file will continue fully and finish, with no other errors
Quote from: eumagga0x2a on March 25, 2018, 04:44:03 PM
Thanks, it doesn't suppress dialogs opened for errors then. Will try to find out what is going on later tonight.
SOLVED
I messed around and done this, and it works great, NO errors and copies Video and Audio from Mkv to MP4
set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy set audiocodec=Copy
for %%f in (*.mkv) do %avidemux% --video-codec %videocodec% --audio-codec %audiocodec% --force-alt-h264 --load "%%f" --save "%%~nf.mp4" --quitOnce again Thanks for getting me advice Cheers
Quote from: jonwren on March 25, 2018, 06:26:10 PM
I messed around and done this, and it works great, NO errors and copies Video and Audio from Mkv to MP4
set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy set audiocodec=Copy
for %%f in (*.mkv) do %avidemux% --video-codec %videocodec% --audio-codec %audiocodec% --force-alt-h264 --load "%%f" --save "%%~nf.mp4" --quit
Just a small nit: --load should always come first, because depending on Avidemux settings, this will reset video codec to a user defined default value. Additionally, the option --force-alt-h264 has been removed from Avidemux since ages.
The reason for the error was most likely missing full path to the .py file so that it was simply never loaded (it works with relative path on Linux, but maybe this doesn't apply either to Windows or to your setup, so that the .py file wasn't located in the folder where the command was run).
Finally, in your command line above you don't set output format, the resulting .mp4 should be really a MKV with .mp4 file name extension.
Just for reference: A more or less correct batch would have been
set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy
set audiocodec=Copy
set outfmt=MP4
for %%f in (*.mkv) do %avidemux% --load "%%f" -video-codec %videocodec% --audio-codec %audiocodec% --output-format %outfmt% --save "%%~nf.mp4" --quit
I have added gatekeeper code to deal with situations when script file provided via command line can't be found at the given location. In the future, users won't face a tinyPy exception message if they pass a wrong path to the --run option.
Great Thanks
I was just wondering if there is a Batch to detect AC3 within Video, as I would like to convert AC3 over to HE-AAC.
I have MediaInfo, but having to manually check every video is a pain.
Also is it ok to change the container AVI to MP4
Thanks
Quote from: jonwren on March 27, 2018, 06:50:36 AM
I was just wondering if there is a Batch to detect AC3 within Video, as I would like to convert AC3 over to HE-AAC.
ffprobe is part of the FFMPEG package. The following batchfile should work from cmd line or drag-and-drop (not tested) for win7 or later.
Find_AC3.bat@echo off
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3" >nul && echo "%%~dpnxF" contains AC3
shift
)
pause
Result using a cmd line of:
Find_AC3.bat "D:\20161130 - OIC Christmas Carols\Video\00000.MTS" "D:\20161130 - OIC Christmas Carols\Video\00001.MTS" *.mp4"D:\20161130 - OIC Christmas Carols\Video\00000.MTS" contains AC3
"D:\20161130 - OIC Christmas Carols\Video\00001.MTS" contains AC3
"D:\00000.mp4" contains AC3
Press any key to continue . . .
The .MTS files are AVCHD media files from my camcorder. Most of the MP4s in D:\ do not contain AC-3 so they produce blank lines.
The portion after "&&" will only execute if the find was successful. With a little more mucking around it would be possible to only run FFMPEG to perform the HE-AAC audio stream conversion if the find was successful.
The ">nul" hides double FIND screen displays of "ac3" to reduce clutter.
"%%~dpnxF" is used instead of %%F as it is not affected by the presence or absence of "" around
*.mp4Dan.
Just a few words to conversion AVI --> MP4: If the video is H.264 or HEVC and contains B-frames, direct conversion will result in a file not smoothly playable in some players like VLC. The reason for that is AVI not storing presentation timestamps while the presence of B-frames means that frames are stored not in the order they are displayed. Avidemux offers a feature to reconstruct missing information by decoding the entire video, but I am not sure it is scriptable.
ok thanks
Quote from: dosdan on March 27, 2018, 08:18:33 AM
Quote from: jonwren on March 27, 2018, 06:50:36 AM
I was just wondering if there is a Batch to detect AC3 within Video, as I would like to convert AC3 over to HE-AAC.
ffprobe is part of the FFMPEG package. The following batchfile should work from cmd line or drag-and-drop (not tested) for win7 or later.
Find_AC3.bat
@echo off
Great cheers Dan
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3" >nul && echo "%%~dpnxF" contains AC3
shift
)
pause
Result using a cmd line of:
Find_AC3.bat "D:\20161130 - OIC Christmas Carols\Video\00000.MTS" "D:\20161130 - OIC Christmas Carols\Video\00001.MTS" *.mp4
"D:\20161130 - OIC Christmas Carols\Video\00000.MTS" contains AC3
"D:\20161130 - OIC Christmas Carols\Video\00001.MTS" contains AC3
"D:\00000.mp4" contains AC3
Press any key to continue . . .
The .MTS files are AVCHD media files from my camcorder. Most of the MP4s in D:\ do not contain AC-3 so they produce blank lines.
The part after "&&" will only execute if the find was successful. With a little more mucking around it would be possible to only run FFMPEG to perform the HE-AAC conversion if the find was successful.
The ">nul" hides FIND screen displays of "ac3" to reduce clutter.
"%%~dpnxF" is used instead of %%F as it is not affected by the presence or absence of "" around *.mp4
Dan.
Hi Dan
I've just tried it and all I get is...
Press any key to continue
I copied and pasted
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3" >nul && echo "%%~dpnxF" contains AC3
shift
)
pause
and made a bat file and placed it inside a folder with AC3 video files, I have double clicked on the bat and have also drag the files into the bat and I still get Press any key to continue
cheers
Quote from: jonwren on March 27, 2018, 09:09:55 AM
Hi Dan
I've just tried it and all I get is...
Press any key to continue
Is the directory FFPROBE.EXE is situated in included in your path list? You can test by going to the cmd prompt and just typing FFPROBE. I see:
C:\Windows\System32>ffprobe
ffprobe version N-90419-g3e3d567761 Copyright (c) 2007-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-openssl --enable-avisynth --extra-cflags=-DLIBTWOLAME_STATIC --enable-libfdk-aac --extra-libs=-lstdc++ --extra-cflags=-DLIBXML_STATIC --enable-version3 --enable-nonfree --disable-debug
libavutil 56. 11.100 / 56. 11.100
libavcodec 58. 15.100 / 58. 15.100
libavformat 58. 10.100 / 58. 10.100
libavdevice 58. 2.100 / 58. 2.100
libavfilter 7. 13.100 / 7. 13.100
libswscale 5. 0.102 / 5. 0.102
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Simple multimedia streams analyzer
usage: ffprobe [OPTIONS] [INPUT_FILE]
You have to specify one input file.
Use -h to get full help or, even better, run 'man ffprobe'.
Dan.
This is what I get
Microsoft Windows [Version 10.0.17120.1]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\jonwr>FFPROBE
ffprobe version 3.4.2 Copyright (c) 2007-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libmfx --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Simple multimedia streams analyzer
usage: ffprobe [OPTIONS] [INPUT_FILE]
You have to specify one input file.
Use -h to get full help or, even better, run 'man ffprobe'.
Perhaps your version of FFPROBE is returning a different string e.g. AC3 or AC-3 instead of ac3. To troubleshoot, try a simpler command on the cmd line, not a batchfile, with a media file that you already know contains an AC-3 audio stream e.g. try just:
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "d:\20161130 - OIC Christmas Carols\Video\00000.MTS"
I see:
codec_name=h264
codec_name=ac3
codec_name=hdmv_pgs_subtitle
codec_name=h264
codec_name=ac3
codec_name=hdmv_pgs_subtitle
Dan.
I get this
C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1"C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
[default @ 000002d4adc36f20]
Failed to parse option string 'noprint_wrappers=1C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4' provided to writer context
Quote from: jonwren on March 27, 2018, 10:32:08 AM
I get this
C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1"C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
[default @ 000002d4adc36f20]
Failed to parse option string 'noprint_wrappers=1C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4' provided to writer context
Add a space before the media filename i.e.
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
I now get this :)
C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
codec_name=h264
codec_name=ac3
Quote from: jonwren on March 27, 2018, 10:44:10 AM
I now get this :)
C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
codec_name=h264
codec_name=ac3
OK, now try this (command on one line):
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3"
If that works increase it to (command on one line):
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3" >nul && echo "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" contains AC3Dan.
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3"
I get...codec_name=ac3
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3" >nul && echo "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" contains AC3
I get..."C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" contains AC3
So the basic command is working fine. The problem must be in the FOR IN () DO loop.
Try this batch file:
Find_AC3.bat
@echo on
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3">nul && echo "%%~dpnxF" contains AC3
shift
)
pause
use it from the cmd line with a file containing AC-3. Since ECHO is ON you will see the lines in the batch file, and then you will see them again, this time with the FOR IN () DO loop interpreted and "%%~dpnxF" expanded:
D:\>Find_AC3.bat "D:\MKV test\test 100.mkv"
I see:
D:\>for %F in ("D:\MKV test\test 100.mkv") do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%~dpnxF" | find "ac3" 1>nul && echo "%~dpnxF" contains AC3
shift
)
D:\>(
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "D:\MKV test\test 100.mkv" | find "ac3" 1>nul && echo "D:\MKV test\test 100.mkv" contains AC3
shift
)
D:\>pause
Press any key to continue . . .
@echo on
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3">nul && echo "%%~dpnxF" contains AC3
shift
)
pause
I get....
C:\Users\jonwr>for %%F in (%*) do (
%%F was unexpected at this time.
C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3">nul && echo "%%~dpnxF" contains AC3
%%~dpnxF: No such file or directory
C:\Users\jonwr>shift
Quote from: jonwren on March 27, 2018, 11:18:53 AM
I get....
C:\Users\jonwr>for %%F in (%*) do (
%%F was unexpected at this time.
That's unusual. In a batch file, (but not at the cmd line), you need to use the double percentage symbols:
%%FBut when the batchfile is run, the first percentage symbol is stripped off, leaving just
%FNotice how mine is doing this and yours is not.
Just my luck, this has to happen to me lol
The same applies to %*
Mine is immediately changed to the command line parameters following the batchfile name, here just a single media file. Again this behaviour is expected inside a batch file as compared to issuing the command at the cmd prompt.
Dan.
This is what am getting in a Batch now...
C:\Users\jonwr\Desktop>for %F in ((null)) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%~dpnxF" | find "ac3" 1>nul && echo "%~dpnxF" contains AC3
shift
)
C:\Users\jonwr\Desktop>pause
Press any key to continue . . .
Try this. Create this batch file in a text editor:
Batch_Paramenter_Parsing.bat
@echo off
echo %%1 is %1
echo %%2 is %2
echo %%3 is %3
echo %%4 is %4
echo %%* is %*
Run it from the cmd prompt with some parameters:
D:\>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
I see:
%1 is 10
%2 is 20
%3 is 30
%4 is 40
%* is 10 20 30 40 50 60 70 80 90
Dan.
C:\Users\jonwr>C:\>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
'C:\' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\jonwr>
Quote from: jonwren on March 27, 2018, 11:49:18 AM
C:\Users\jonwr>C:\>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
'C:\' is not recognized as an internal or external command,
operable program or batch file.
No, use:
batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
Nothing happens it just returns
C:\Users\jonwr>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
C:\Users\jonwr>
I think you're getting confused with the cmd prompt. The LHS, before the ">", shows which drive and which directory you are currently situated in. For example:
C:\Users\jonwr> means that you are on C: drive, in the jonwr subdirectory which is under the Users directory
So, to change directory:
C:\Users\jonwr> cd .. (meaning "jump up one level") or cd C:\users or cd \users would change the prompt and your location to:
C:\Users>
And, from there cd C:\users\jonwr or cd \users\jonwr or cd jonwr would change you back to:
C:\Users\jonwr>
And if you had a D: drive,
C:\Users\jonwr> D: would change you to
D:\> (the root directory of D: drive)
Quote from: jonwren on March 27, 2018, 12:03:09 PM
Nothing happens it just returns
C:\Users\jonwr>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
C:\Users\jonwr>
Edit this batchfile in an text editor, change @ECHO OFF to @ECHO ON, save your change and then rerun the command line under discussion.
Quote from: dosdan on March 27, 2018, 12:13:32 PM
I think you're getting confused with the cmd prompt. The LHS, before the ">", shows which drive and which directory you are currently situated in. For example:
C:\Users\jonwr> means that you are on C: drive, in the jonwr subdirectory which is under the Users directory
So, to change directory:
C:\Users\jonwr> cd .. (meaning "jump up one level") or cd C:\users or cd \users would change the prompt and your location to:
C:\Users>
And, from there cd C:\users\jonwr or cd \users\jonwr or cd jonwr would change you back to:
C:\Users\jonwr>
And if you had a D: drive,
C:\Users\jonwr> D: would change you to
D:\> (the root directory of D: drive)
I really don't understand this.
I've changed @ECHO OFF to @ECHO ON in my Batch
and then in CMD batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
I still get the same result it returns to
C:\Users\jonwr>
Quote from: jonwren on March 27, 2018, 12:26:23 PM
I really don't understand this.
I've changed @ECHO OFF to @ECHO ON in my Batch
and then in CMD batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
I still get the same result it returns to
C:\Users\jonwr>
I forgot to mention: from any location typing
DIR or
dir will show you the files in this directory and any sub-directories (
aka "folders") off of it.
Assuming you have created the
batch_parameter_parsing.bat text file in your current directory, typing
TYPE batch_parameter_parsing.bat or
type batch_parameter_parsing.batwill show its contents on your screen. Please do this and report what you see.
Dan.
I've typed DIR in CMD and got this...
C:\Users\jonwr>DIR
Volume in drive C has no label.
Volume Serial Number is E041-BA2F
Directory of C:\Users\jonwr
27-Mar-18 04:32 PM <DIR> .
27-Mar-18 04:32 PM <DIR> ..
24-Mar-18 09:33 PM <DIR> .atom
07-Mar-18 04:06 PM <DIR> .BestSoft
06-Mar-18 03:44 PM <DIR> .swt
19-Mar-18 03:59 PM <DIR> 3D Objects
27-Mar-18 04:22 PM 0 batch_parameter_parsing.bat
27-Mar-18 04:32 PM 0 cd
19-Mar-18 03:59 PM <DIR> Contacts
27-Mar-18 03:44 PM <DIR> Desktop
26-Mar-18 05:05 PM <DIR> Documents
26-Mar-18 08:38 PM <DIR> Downloads
19-Mar-18 03:59 PM <DIR> Favorites
06-Mar-18 03:57 PM 22 id_usuario.txt
21-Mar-18 04:03 PM <DIR> Links
19-Mar-18 03:59 PM <DIR> Music
24-Mar-18 02:54 PM <DIR> OneDrive
21-Mar-18 11:20 AM <DIR> Pictures
19-Mar-18 03:59 PM <DIR> Saved Games
19-Mar-18 03:59 PM <DIR> Searches
21-Mar-18 11:20 AM <DIR> Videos
3 File(s) 22 bytes
18 Dir(s) 724,492,279,808 bytes free
typing
TYPE batch_parameter_parsing.bat
or
type batch_parameter_parsing.bat
in CMD
I got this...
C:\Users\jonwr>TYPE batch_parameter_parsing.bat
C:\Users\jonwr>type batch_parameter_parsing.bat
C:\Users\jonwr>
Quote from: jonwren on March 27, 2018, 12:40:02 PM
27-Mar-18 04:22 PM 0 batch_parameter_parsing.bat
27-Mar-18 04:32 PM 0 cd
Two things:
"0" is the size of the file in bytes. So batch_ parameter_parsing.bat has no contents. This can't be the file you are editing. If it is, you have just wiped its contents, probably by saving it incorrectly. That's why
TYPE batch_parameter_parsing.bat is not displaying any lines of code. What text editor are you using?
You should not have a empty file titled "cd" as this is an important Windows internal command. This may prevent you changing directories. To remove it, type at the cmd prompt:
DEL CD and then type
DIR at the cmd prompt again to check.
C:\Users\jonwr>DEL CD
Could Not Find C:\Users\jonwr\CD
C:\Users\jonwr>DEL CD DIR
Could Not Find C:\Users\jonwr\CD
C:\Users\jonwr>dir
Volume in drive C has no label.
Volume Serial Number is E041-BA2F
Directory of C:\Users\jonwr
27-Mar-18 04:52 PM <DIR> .
27-Mar-18 04:52 PM <DIR> ..
24-Mar-18 09:33 PM <DIR> .atom
07-Mar-18 04:06 PM <DIR> .BestSoft
06-Mar-18 03:44 PM <DIR> .swt
19-Mar-18 03:59 PM <DIR> 3D Objects
27-Mar-18 04:22 PM 0 batch_parameter_parsing.bat
19-Mar-18 03:59 PM <DIR> Contacts
27-Mar-18 04:51 PM <DIR> Desktop
26-Mar-18 05:05 PM <DIR> Documents
27-Mar-18 04:48 PM <DIR> Downloads
19-Mar-18 03:59 PM <DIR> Favorites
06-Mar-18 03:57 PM 22 id_usuario.txt
21-Mar-18 04:03 PM <DIR> Links
19-Mar-18 03:59 PM <DIR> Music
24-Mar-18 02:54 PM <DIR> OneDrive
21-Mar-18 11:20 AM <DIR> Pictures
19-Mar-18 03:59 PM <DIR> Saved Games
19-Mar-18 03:59 PM <DIR> Searches
21-Mar-18 11:20 AM <DIR> Videos
2 File(s) 22 bytes
18 Dir(s) 724,487,135,232 bytes free
C:\Users\jonwr>
Quote from: jonwren on March 27, 2018, 12:57:13 PM
C:\Users\jonwr>DEL CD
Could Not Find C:\Users\jonwr\CD
Well the CD filename is gone - that's the important thing.
What text editor are you using? In the editor are you using File | Save each time to save your changes?
Notepad
selecting Save after etc edit
Quote from: dosdan on March 27, 2018, 01:01:09 PM
Quote from: jonwren on March 27, 2018, 12:57:13 PM
C:\Users\jonwr>DEL CD
Could Not Find C:\Users\jonwr\CD
Well the CD filename is gone - that's the important thing.
What text editor are you using? In the editor are you using File | Save each time to save your changes?
If the editor shows lines in
batch_parameters_parsing.bat use File | Close if the editor has it and then type
DIR at the cmd prompt to check if its filesize has increased.
Quote from: jonwren on March 27, 2018, 01:03:30 PM
Notepad
selecting Save after etc edit
Any when you reopen
batch_parameters_parsing.bat in Notepad are you seeing any lines of code this time?
This is what is shown in editor
Before and After DIR is the same
@echo on
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3">nul && echo "%%~dpnxF" contains AC3
shift
)
pause
Quote from: jonwren on March 27, 2018, 01:09:19 PM
This is what is shown in editor
@echo on
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3">nul && echo "%%~dpnxF" contains AC3
shift
)
pause
OK. Now exit Notepad. If
DIR still shows 0 as the filesize of
Batch_parameters_parsing.bat, this would indicate the file that you had open in Notepad is not the same file as in this directory. (You can't have two files with the same filename in the same directory, but you can if they are in different drives or directories.)
from Batch
C:\Users\jonwr>Batch_parameters_parsing.bat
'Batch_parameters_parsing.bat' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\jonwr>
@echo on
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3">nul && echo "%%~dpnxF" contains AC3
shift
)
pause
DIR
C:\Users\jonwr>DIR
Volume in drive C has no label.
Volume Serial Number is E041-BA2F
Directory of C:\Users\jonwr
27-Mar-18 04:52 PM <DIR> .
27-Mar-18 04:52 PM <DIR> ..
24-Mar-18 09:33 PM <DIR> .atom
07-Mar-18 04:06 PM <DIR> .BestSoft
06-Mar-18 03:44 PM <DIR> .swt
19-Mar-18 03:59 PM <DIR> 3D Objects
27-Mar-18 04:22 PM 0 batch_parameter_parsing.bat
19-Mar-18 03:59 PM <DIR> Contacts
27-Mar-18 05:21 PM <DIR> Desktop
26-Mar-18 05:05 PM <DIR> Documents
27-Mar-18 04:59 PM <DIR> Downloads
19-Mar-18 03:59 PM <DIR> Favorites
06-Mar-18 03:57 PM 22 id_usuario.txt
21-Mar-18 04:03 PM <DIR> Links
19-Mar-18 03:59 PM <DIR> Music
24-Mar-18 02:54 PM <DIR> OneDrive
21-Mar-18 11:20 AM <DIR> Pictures
19-Mar-18 03:59 PM <DIR> Saved Games
19-Mar-18 03:59 PM <DIR> Searches
21-Mar-18 11:20 AM <DIR> Videos
2 File(s) 22 bytes
18 Dir(s) 724,477,853,696 bytes free
C:\Users\jonwr>
OK, I'm fairly certain you've got 2 batch_parameter_parsing.bat files in your system. What you are opening in Notepad is probably in your documents folder. Do a Windows search for batch_parameter_parsing.bat and look at their location and size.
Windows hides the extension of files it knows how to handle to avoid confusing novices. Unfortunately this can confuse them when they want to create batch files (a text file containing a series of lines of code) because what looks like a batch file called batch_parameter_parsing.bat might actually be batch_paramenter_parsing.bat.txt
The later, although having the same contents, is not an executable file.
Quote from: jonwren on March 27, 2018, 01:24:57 PM
C:\Users\jonwr>Batch_parameters_parsing.bat
'Batch_parameters_parsing.bat' is not recognized as an internal or external command,
operable program or batch file.
Sorry that should have been
Batch_parameter_parsing.bat not
Batch_parameters_parsing.bat
Anyway, according to DIR, the one in C:\Users\jonwr has no contents.
Right I did another scan and found 2
This one was empty so I put it in the bin
C:\Users\jonwr
this one is 88 Bytes
C:\Users\jonwr\Desktop\AC3_TEST\Batch_parameter_parsing.bat
I went back to CMD and did
Batch_parameter_parsing.bat
This is the results
Microsoft Windows [Version 10.0.17120.1]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>Batch_parameter_parsing.bat
'Batch_parameter_parsing.bat' is not recognized as an internal or external command,
operable program or batch file.
C:\WINDOWS\system32>
Quote from: jonwren on March 27, 2018, 02:28:37 PM
this one is 88 Bytes
C:\Users\jonwr\Desktop\AC3_TEST\Batch_parameter_parsing.bat
C:\WINDOWS\system32>Batch_parameter_parsing.bat
'Batch_parameter_parsing.bat' is not recognized as an internal or external command,
operable program or batch file.
C:\WINDOWS\system32>
OK.
Batch_parameter_parsing.bat is not in your current location (the C:\WINDOWS\system32 dictionary). So if you want to execute it you have 3 options:
- Specify the full path in front of the command:
C:\Users\jonwr\Desktop\AC3_TEST\Batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
- First change to the directory it's located in and then execute it (two separate commands):
CD \Users\jonwr\Desktop\AC3_TEST (no need to specify C: if you are already situated on that drive)
Batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
- Either copy Batch_parameter_parsing.bat to a directory that is already in the PATH list of directories, or add its location (C:\Users\jonwr\Desktop\AC3_TEST) to the list of directories in your PATH list. When you try to run a executable (a file with .COM, .EXE or .BAT file extension), and you don't specify its location, the operating system looks first in your current location and then in the locations in the PATH list. If it's in one of these locations you can use just:
Batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
while situated in any location.
For example, you might have lot of little utility programs and batch files which you want to be able to run from anywhere. Type
PATH at the CMD line. Mine shows:
[/list]
PATH=C:\Mingw\local64\bin-video;C:\Mingw\local64\bin-audio;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86);C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\GNU\GnuPG\pub;C:\Program Files (x86)\GNU\GnuPG;C:\Program Files (x86)\WinMerge;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\QuickTime\QTSystem\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files\nodejs\;C:\Program Files\gnuplot\bin;C:\Users\Dan\AppData\Local\Microsoft\WindowsApps;d:\YouTube_dl;C:\Users\Dan\AppData\Roaming\npm;
Now we make a C:\Utilities directory. From anywhere on C: type
MD \UtilitiesChange to this directory
CD \UtilitiesThe prompt will now show
C:\Utilities> to indicate where you are.
Copy batch_parameter.bat to here:
Copy \Users\jonwr\Desktop\AC3_TEST\batch_parameter.batBecause you did not specify a destination (i.e.
Copy \Users\jonwr\Desktop\AC3_TEST\batch_parameter.bat \Utilities), it will use your current location as the destination of the file copy. Confirm the copy was successful by typing:
DIRNow we need to add C:\Utilities to your path list. In Windows, go to Control Panel | System | Advanced System Settings | Environment Variables. In the "User Variables for jonwr" section, highlight the "Path" line and then click on "Edit". Click on "New", type in
c:\utilities (case is not important in Windows) and click on OK, and then OK again, and OK again to finish closing all these windows.
We nee to load a new instance of CMD, as the current instance will not be aware of the change in the path yet. If the CMD window is still open, close it by typing EXIT, then type CMD again to open as a new instance. Type PATH to check again. I see (scroll to the end of the line):
PATH=C:\Mingw\local64\bin-video;C:\Mingw\local64\bin-audio;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86);C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\GNU\GnuPG\pub;C:\Program Files (x86)\GNU\GnuPG;C:\Program Files (x86)\WinMerge;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\QuickTime\QTSystem\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files\nodejs\;C:\Program Files\gnuplot\bin;C:\Users\Dan\AppData\Local\Microsoft\WindowsApps;d:\YouTube_dl;C:\Users\Dan\AppData\Roaming\npm;c:\utilities;
Now you can type
Batch_parameter_parsing.bat (or just
batch_parameter_parsing)
10 20 30 40 50 60 70 80 90 from anywhere and it should execute.
Note: when working at the cmd prompt, you have a few aids. The F3 key will help you auto-complete paths and filesnames. For example, type:
CD \u [Press F3 once or twice]. It should complete to
CD \Users
Continue typing
CD \Users
\j Press F3 and you'll get:
CD \Users\jonwr
Same with copying a file e.g if operating from c:\users\jonwr
c:\users\jonwr>
copy des [F3]
copy Desktop
\AC [F3]
copy Desktop\AC3_TEST
\ba [F3]
copy Desktop\AC3_TEST\batch_parameter_parsing.bat
\u [F3]
copy Desktop\AC3_TEST\batch_parameter_parsing.bat \utilities
You can also use Up-Arrow to bring back previous commands, edit part of it and then press F3 again to try for a match.
You can mark a string of characters at the prompt by clicking-and-dragging the L. mouse button. Press Enter to copy the highlighted portion to the Windows clipboard.
You can paste from the clipboard which can have been filled from within the cmd prompt window, or from a copying operation in another program like Notepad (most windows programs use Ctrl-C for Copy), using the Ctrl-V (Paste) hot-key.
Dan.
Thanks @dosdan !
Any idea how to make it work with directories that contain other files than video ? It fails when I have folders with text files in it :/
Quote from: seyar on December 02, 2018, 12:23:46 PM
Any idea how to make it work with directories that contain other files than video ? It fails when I have folders with text files in it :/
If running the batchfile from the cmd line in the current directory, specify the filetypes you want by nominating one or more wildcards+file extensions e.g.
Find_AC3.bat *.mp4 *.mtsIf operating by drag-and-drop from the Windows desktop, open the directory first and sort the icons (or details) by filetype. (For this type of work you really should select the Windows option that will not hide known file extensions in a directory listing - hiding them is only useful for novices.) Select a block of media files, say all the MP4s, using the standard Windows L.click (start of block) & Shift-L.Click (end of block) and then drag the selected group onto the
Find_AC3.bat icon.
Dan.