Newbie : How to Copy Video & Audio folder from MKV to MP4 Script

Started by jonwren, March 24, 2018, 02:09:01 PM

Previous topic - Next topic

jonwren

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


jonwren

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>

dosdan

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.

dosdan

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.

dosdan

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.

jonwren

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>


dosdan

    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 \Utilities

    Change to this directory
    CD \Utilities

    The 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.bat

    Because 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:
    DIR

    Now 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.

    seyar

    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 :/

    dosdan

    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 *.mts



    If 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.