Help in parameters of button bar
Moderators: Hacker, petermad, Stefan2, white
Help in parameters of button bar
Hi,
I have setup a batch file that takes 2 parameter from the total commander's button bar. The batch file reads like this:
[face=courier]@echo off
cls
setlocal enabledelayedexpansion
set videofilename=%2
set Videofilename=!videofilename:~0,-12!"
C:\totalcmd\Tools\mkvpropedit.exe %1 -s title=%videofilename%
[/face]
On total commander's button bar, I have the parameters like so:
Command: %COMMANDER_PATH%\Tools\SetMKVTitle.cmd
Parameters: %P%S %S
Start path: %COMMANDER_PATH%\Tools\
Now when I select the respective video file and press the button bar, the whole thing works fine.
But when I select multiple video files, the batch file complains that I put too many filenames onto MKVpropedit.exe...
I think it is a case of me selecting the wrong parameters in the button bar...but I can't figure out how else to solve this...
Some help please? Many thanks
I have setup a batch file that takes 2 parameter from the total commander's button bar. The batch file reads like this:
[face=courier]@echo off
cls
setlocal enabledelayedexpansion
set videofilename=%2
set Videofilename=!videofilename:~0,-12!"
C:\totalcmd\Tools\mkvpropedit.exe %1 -s title=%videofilename%
[/face]
On total commander's button bar, I have the parameters like so:
Command: %COMMANDER_PATH%\Tools\SetMKVTitle.cmd
Parameters: %P%S %S
Start path: %COMMANDER_PATH%\Tools\
Now when I select the respective video file and press the button bar, the whole thing works fine.
But when I select multiple video files, the batch file complains that I put too many filenames onto MKVpropedit.exe...
I think it is a case of me selecting the wrong parameters in the button bar...but I can't figure out how else to solve this...
Some help please? Many thanks
If you always need to pass focused file to program, just use %P%N "%N" parameters. Your %P%S and %S pass paths/names for all selected files, and I doubt that it is what you want.
Actually, you don't really pass both path to file and filename to batch because batch is able to extract just name from path:
In such case you only need to pass %P%N.
Actually, you don't really pass both path to file and filename to batch because batch is able to extract just name from path:
Code: Select all
@echo off
cls
setlocal enabledelayedexpansion
set videofilename=%~n1
set Videofilename=!videofilename:~0,-12!"
C:\totalcmd\Tools\mkvpropedit.exe %1 -s title="%videofilename%"
Thanks MVV.
I tried your recommendations and set Videofilename = %~n1 and set parameter to pass %P%N only.
I get an error message when I process a video file.
Error: More than one file name has been given (e:\A Knights tale\A Knights Tale (2001).mkv' and 'Knights ').
Does not seem to work...any ideas?
Edit: By default, the program I am running i.e. MKVpropedit.exe is not capable of taking in multiple files on the commandline...I wonder if this is the reason the script is failing...
Would it be more feasible for me to get the buttonbar to consolidate all the files that will need to be processed and put these into some kind of array for the batch file to loop through one by one?
How do you deal with programs which cannot take multiple files on the commandline but yet want Totalcommander to process all these selected files...
I tried your recommendations and set Videofilename = %~n1 and set parameter to pass %P%N only.
I get an error message when I process a video file.
Error: More than one file name has been given (e:\A Knights tale\A Knights Tale (2001).mkv' and 'Knights ').
Does not seem to work...any ideas?
Edit: By default, the program I am running i.e. MKVpropedit.exe is not capable of taking in multiple files on the commandline...I wonder if this is the reason the script is failing...
Would it be more feasible for me to get the buttonbar to consolidate all the files that will need to be processed and put these into some kind of array for the batch file to loop through one by one?
How do you deal with programs which cannot take multiple files on the commandline but yet want Totalcommander to process all these selected files...
You can use a batch file like this:
Call it from a button with parameters:
The "For" part gets called for every file.
Code: Select all
@echo off
setlocal enabledelayedexpansion
rem Button Parameter "%F" "%P" "%T"
set tc_lst=%1
set tc_src=%2
set tc_dst=%3
echo %tc_lst%
echo %tc_src%
echo %tc_dst%
if -%3==- echo First parameter must be filelist path, second and third - source and target path. && pause && goto :EOF
for /F "usebackq delims=" %%I in (%tc_lst%) do (
echo Exp: %%~I
echo Full Path: %%~fI
echo LW: %%~dI
echo Path: %%~pI
echo File Name: %%~nI
echo Extension: %%~xI
echo ShortPath: %%~sI
echo Attrb: %%~aI
echo Date Time: %%~tI
echo Size: %%~zI
echo ----------------------------
set concat=!concat! %%~nI
)
echo %concat%
echo !concat!
pause
cls
endlocal
Code: Select all
"%F" "%P" "%T"
Thanks ZoSTeR very much. Thanks to your code, I think I am very close.
This is what I adatpted out of your code.
While the "echo statement" seems to reflect the things I would like to run on the command line, there must be something amiss with the actual MKVpropedit.exe program.
This is the error I get:
Any ideas?
EDIT: the video files structure are like so:
e:\TEST\Video files\A Knights Tale (2001).mkv
e:\TEST\Video files\Beetlejuice (1988).mkv
This is what I adatpted out of your code.
Code: Select all
@echo off
setlocal enabledelayedexpansion
rem Button Parameter "%F" "%P" "%T"
set tc_lst=%1
set tc_src=%2
set tc_dst=%3
if -%3==- echo First parameter must be filelist path, second and third - source and target path. && pause && goto :EOF
for /F "usebackq delims=" %%I in (%tc_lst%) do (
set videofilename=%%~nI
echo C:\totalcmd\Tools\mkvpropedit.exe %%~fI -s title ="!videofilename:~0,-7!"
C:\totalcmd\Tools\mkvpropedit.exe %%~fI -s title ="!videofilename:~0,-7!"
echo.
)
pause
cls
endlocal
This is the error I get:
Code: Select all
C:\totalcmd\Tools\mkvpropedit.exe e:\TEST\Video files\A Knights Tale (2001).mkv -s title ="A Knights Tale"
Error: More than one file name has been given ('e:\TEST\Video' and 'files\A').
C:\totalcmd\Tools\mkvpropedit.exe e:\TEST\Video files\Beetlejuice (1988).mkv -s title ="Beetlejuice"
Error: More than one file name has been given ('e:\TEST\Video' and 'files\Beetlejuice').
EDIT: the video files structure are like so:
e:\TEST\Video files\A Knights Tale (2001).mkv
e:\TEST\Video files\Beetlejuice (1988).mkv
Ok. It looks like I miss a couple of quotation marks.
I adjusted these 2 lines slightly...
echo C:\totalcmd\Tools\mkvpropedit.exe "%%~fI" --s "title= "!videofilename:~0,-7!"
C:\totalcmd\Tools\mkvpropedit.exe "%%~fI" -s "title=!videofilename:~0,-7!"
And the code is now running ok. Success!
Thanks ZoSTeR!! Greatly appreciated your help.
I adjusted these 2 lines slightly...
echo C:\totalcmd\Tools\mkvpropedit.exe "%%~fI" --s "title= "!videofilename:~0,-7!"
C:\totalcmd\Tools\mkvpropedit.exe "%%~fI" -s "title=!videofilename:~0,-7!"
And the code is now running ok. Success!
Thanks ZoSTeR!! Greatly appreciated your help.
Batch Editing the title field/property of matroska/mkv video
josephlo: I happened to have at one point similar problems of yours with the bat file and so I arrived to this thread wich happened to be looking to the same final and actual purpose!!
But as I had never used TC buttons my approach was different:
1. have a folder with the bat files (and video apps)
2. temporary move the mkv files to this folder
3. run bat (change mkv.s)
4 Return the mkv.s to their own folder
I certainly would like better approach like yours that seems to not involve temporary moving the files, (I will learn it) but anyway I was already successfull with my approach, so I will share it for anyones interested, as we all know the lack of tags in mkv is a terrible condition.
But as I had never used TC buttons my approach was different:
1. have a folder with the bat files (and video apps)
2. temporary move the mkv files to this folder
3. run bat (change mkv.s)
4 Return the mkv.s to their own folder
I certainly would like better approach like yours that seems to not involve temporary moving the files, (I will learn it) but anyway I was already successfull with my approach, so I will share it for anyones interested, as we all know the lack of tags in mkv is a terrible condition.
Code: Select all
cambiar campo titulo de mkv
@echo off
for /R %%x in (*.mkv) do
rem %%x es la ruta completa del archivo incluyendo extension
setlocal
set arch=%%x
setlocal
set var=%%~nx
rem nombre puro
@echo 3 %var:~3,56%
rem 3 arriba esta nombre puro y cortado del archivo
setlocal
set nomOK=%var:~3,57%
rem arriba guardando nombre puro y cortado del archivo
echo 4%nomOK%
mkvpropedit "%arch%" --edit info --set "title=The Doors - %nomOK%"
)
endlocal
rem pause