While the answer that @notjustme provided works, I have a small addition to it: the output variable should include the drive and path of the filename that was passed to the batch file to have the output file be created in the same directory as the source file.
"C:\Users\Professional\NVEncC_5.24_x64\NVEncC64.exe" --codec h265 --preset quality --profile main10 --tier high -i "%~f1" -o "%~d1%~p1%~n1-Q27.mkv"
pause
The filename that is passed when you right-click --> SendTo --> your_batch_file.cmd is referenced as %1
or the first parameter. Because it is a filename, it can be parsed and expanded further into its parts.
And as mentioned by @notjustme:
%~f1
expands %1 (the filename passed) to its fully qualified path name
%~n1
expands %1 to its file name only
But there is also:
%~d1
expands %1 to its drive letter
%~p1
expands %1 to its full path
%~x1
expands %1 to its file extension only
If you do not add the %~d1%~p1
to the output file variable, by default, the transcoded file will not be created in the same directory as the source file; rather, it will be created in the directory where your batch file is located.
(Additionally, given rigaya's rather short development windows with NVEncC, you might want to install it to a more generally-named directory that does not include the versioning, e.g., "C:\Users\Professional\NVEncC\"
instead of "C:\Users\Professional\NVEncC_5.24_x64\"
. That way, you do not have to update its path in your batch file with every new release.)