VideoHelp Forum




+ Reply to Thread
Results 1 to 5 of 5
  1. Recently I did many tests and figured out the optimal settings for VVC conversion. I want to create two executables, fftest and ffconvert. These are meant to work alongside the FFMPEG-VVC project. fftest will create a whole battery of test files by the simple act of dragging and dropping the file to be tested onto fftest.exe. ffconvert will also work via drag and drop and will create a vvc/aac mkv file including any subs if available. These two files will effectively be just batch scripts running invisibly, I make them exe because I can add icons and include temporary files that way, like the required ffmpeg.exe file. I'm more than familiar with DOS and with ffmpeg and the FFMPEG-VVC project, but the thing I'm having trouble figuring out is how to make the batch files detect the name of the file being dropped and use it in my commands. I never did that before, but it's literally the last piece in my puzzle. Can someone provide an example?
    Last edited by imkira3; 7th Oct 2023 at 17:56.
    Quote Quote  
  2. Example: https://forum.videohelp.com/threads/377677-Video-batch-files#post2469186

    Dropped filepath would be referd to as %1, but perhaps better way is to use "%~1" if dealing with filepaths.

    It is basically a first argument. If dropping two files, you'd use %1 and %2 in your script.
    Quote Quote  
  3. Originally Posted by _Al_ View Post
    Example: https://forum.videohelp.com/threads/377677-Video-batch-files#post2469186

    Dropped filepath would be referd to as %1, but perhaps better way is to use "%~1" if dealing with filepaths.

    It is basically a first argument. If dropping two files, you'd use %1 and %2 in your script.
    Ah wonderful! Thanks man, now I can get back to work
    Quote Quote  
  4. Hmmm okay, I tried a small test command to see if I understood the concept properly. It works fine, but with one slight error. The input file was called Test.avi but the output file is Test.avi.mkv instead of Test.mkv. Did I do something wrong?

    Code:
    ffmpeg -i "%~1" -c:v copy "%~1.mkv"
    pause
    Okay I got it, just had to change it to this:

    Code:
    ffmpeg -i "%~1" -c:v copy "%~n1.mkv"
    pause
    Last edited by imkira3; 8th Oct 2023 at 00:09.
    Quote Quote  
  5. if dealing with an unknown number of dropped files you just might use something like this:
    Code:
    @echo off
    rem processing unknown number of arguments
    
    :get_argument
    if "%~1"=="" (goto end) else (call :process "%~1")
    shift
    goto get_argument
    
    :process <filepath>
    echo processing "%~1"
    ffmpeg -i "%~1" -c:v copy "%~n1.mkv"
    goto :eof
    
    :end
    echo No more arguments, press any key to exit ... & pause>nul & exit
    I posted this example deliberately to show that a dropped file behaves exactly the same as if it was an argument for that batch file. Same as if you'd call a subroutine in windows batch script. In our case subroutine process which has one argument. So within that subroutine/function that argument becomes %1 as well. Even if you pass that filepath as hardcoded, example such as:
    Code:
    call :process "D:\my_file.mp4"
    , it still becomes %1 in that process subroutine, just locally within that subroutine. This is the reason to use subroutines in batch scripts as much as possible (as in other languages), it makes things more readable and clean.

    That text between <> characters is just a note, in our case <filepath>, to keep a track what type of argument that passed %1 actually is. It is really helpful if there is many arguments or there are subroutines within subroutines. I know subroutines could be deep as six or seven (subroutines within subroutines) and it is still ok. Not sure what is maximum.

    command "shift" just shifts arguments, %2 becomes %1, %3 becomes %2 etc.
    Last edited by _Al_; 8th Oct 2023 at 13:06.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!