Windows 10: Trouble with batch files and paths

Discus and support Trouble with batch files and paths in Windows 10 Support to solve the problem; Running win 10 v 1909 build 18363.720. I am pretty green with batch files and paths. I am trying to automate and editing process with mkvpropedit on a... Discussion in 'Windows 10 Support' started by Machinist60, Apr 14, 2020.

  1. Trouble with batch files and paths


    Running win 10 v 1909 build 18363.720.

    I am pretty green with batch files and paths. I am trying to automate and editing process with mkvpropedit on a bunch of MKV files.
    I put the bat file in the same folder as the mkvs.
    Batch file contains:

    @echo off
    for %%a in (*.mkv) do mkvpropedit --edit track:s1 --set flag-default=1 "%%~na.mkv"
    pause

    When run mkvpropedit is not recognized as a command etc. I notice that the errors are written back to the bat file replacing the commands. How to avoid this?

    I have added the registry key
    "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\mkvpropedit.exe" with data "C:\Program Files\mkvpropedit.exe" and the system restarted.

    I believe the path to mkvpropedit is the problem. The path to MKVToolNnix GUI executes fine. mkvpropedit.exe is in the same folder as MKVToolNnix GUI.exe. I don't understand why it is not found.
    I notice that the icons for the exes are all slightly different, does this have any bearing on the issue?
    I have read that it is better to edit the registry rather than environment variables. What is generally recommended and why doesn't the key given above provide the path?
    Any help will be much appreciated.

    :)
     
    Machinist60, Apr 14, 2020
    #1
  2. fahnix Win User

    Batch files fail pathing and [%04d]

    1 When running in Administrator mode batch files automatically take on the Windows\System32 folder unless a prefix is added to the top of the file.

    command example: copy file1.txt "C:\Users\Public\Test\."

    result copies file in current folder to "C:\Users\Public\Test\file1.txt"

    result from batch file as admin is an error stating "File not found" because Admin mode attempts to call commands listed in file from [Windows\System32] folder.

    include [cd %~dp0] at top of batch file to ensure commands run from the folder the batch file resides in.

    2 When running ffmpeg.exe in one folder and writing files to another folder from a batch file Windows automatically pastes the entire path and the batch file name prior to every attempted file write.

    ffmpeg command example :

    bin\ffmpeg.exe -i "C:\Users\JoeMatize\Videos\Logitech Webcam\video 3.wmv" -r 15 "frames-%04d.bmp"

    then windows creates 15 frames per second naming files [frames-0001.bmp] through [frames-0015.bmp] for the 1st second and continuing through the entire file

    But ffmCmd.bat file contains the command attempts to create the output file as...

    "C:\_dev\_Video\FFMPeg_Zeranoe\ffmpeg-20160517-git-af3e944-win64-static\ffmCmd.bat4d.bmp"

    ffmpeg fails when it is unable to acquire a new name for the sequential files.

    is there another command that will fix the batch call to ffmpeg, like the one that fixes the administrative mode path?

    When will Microsoft fix the batch files so they work consistently across the board?
     
    fahnix, Apr 14, 2020
    #2
  3. oily_17 Win User
    Batch Files Knowledge Base

    Don't use batch files very much but one I find useful is for creating a list of files in a directory.
    Just copy the text below into Notepad and save as Filelist.bat

    dir /a /-p /o:gen >filelist.txt

    When you run it from a folder it will create a Filelist.txt file,in the same folder, that lists all the files in that folder.Useful when you are too lazy to type all the files out yourself.
     
    oily_17, Apr 14, 2020
    #3
  4. Trouble with batch files and paths

    Batch Files Knowledge Base

    Very nice and usefull thanks for contributing.
     
    AphexDreamer, Apr 14, 2020
    #4
Thema:

Trouble with batch files and paths

Loading...
  1. Trouble with batch files and paths - Similar Threads - Trouble batch files

  2. Batch File

    in Windows 10 Software and Apps
    Batch File: Hi, I am trying to create a batch file to determine whether a user account is signed on.I don't have enough experience to get it to @Echo it worked. Any advice please.Batch file:REM Query whether user SBackup is active@echo onsetlocal enabledelayedexpansionset...
  3. Batch Files

    in Windows 10 Gaming
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  4. Batch Files

    in Windows 10 Software and Apps
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  5. Batch Files

    in Windows 10 Network and Sharing
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  6. How to get my own path in a batch-file.

    in Windows 10 Network and Sharing
    How to get my own path in a batch-file.: Default answer is %~dp0. And most times this will work fine. But there is a bug in cmd.exe which will prevent this from working correctly under certain circumstances if you use double quotes to call the batch. Double quotes are necessary if the name or path of the batch file...
  7. Having Trouble changing the file path of 'This PC' subfolders

    in Windows 10 Network and Sharing
    Having Trouble changing the file path of 'This PC' subfolders: I would like to change the file path of 'documents' located in the 'This PC' folder from:C:\Users\adii8\OneDrive\Documents -> C:\Users\adii8\DocumentsIn other words, I want to get rid of One Drive acting as an intermediary for all my files.However, when I go through the...
  8. trouble in entering a path

    in Windows 10 Network and Sharing
    trouble in entering a path: Good morning sirs, I'm having trouble setting a path in my ODBC properties: [ATTACH] But if i paste the same path on file explorer i have no trouble. How is it possible?...
  9. Create batch files with Batch?

    in Windows 10 Software and Apps
    Create batch files with Batch?: How to create Batch and VBS files with Batch? So I write a batch file which I then convert to exe that creates new folders in a certain directory and then creates batch and VBS files with a certain content and saves them in the created folder. So it's similar to a program...
  10. Batch File

    in Windows 10 Support
    Batch File: I need a batch file to create a folder with sub folders. The sub folders will be named the current date, they will go in a folder on c drive. For example we can call the folder test and it would be in documents on c drive. Every time we run the batch file it would create a...