A Button for translate selected file name

English support forum

Moderators: Stefan2, white, sheep, Hacker

Post Reply
Junior Member
Junior Member
Posts: 24
Joined: 2017-01-01, 01:13 UTC

A Button for translate selected file name

Post by *drbeat » 2019-02-24, 21:09 UTC

Translate selected file names without extension and send to external program like Qtranslate via button would be useful.

User avatar
Power Member
Power Member
Posts: 3313
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: A Button for translate selected file name

Post by *Horst.Epp » 2019-02-25, 07:31 UTC

And why don't you make that button for yourself ?
This is of course only possible if the program has command line parameters.
Windows 10 Home x64 May 2019 Update, Version 1903 (OS Build 18362.116)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GH, 16GB RAM
TC 9.22a x64 and x86, Everything (x64)

Junior Member
Junior Member
Posts: 24
Joined: 2017-01-01, 01:13 UTC

Re: A Button for translate selected file name

Post by *drbeat » 2019-02-25, 14:15 UTC

The problem is copy file names without extension, how can I do that?

User avatar
Power Member
Power Member
Posts: 8341
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark

Re: A Button for translate selected file name

Post by *petermad » 2019-02-25, 14:18 UTC

Use %O in stead of %N as the parameter
License #524 (1994)
Danish Total Commander Translator
TC 9.22a 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 64bit, 'Everything' (x64) and TC 3.0b3 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

User avatar
Power Member
Power Member
Posts: 6535
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: A Button for translate selected file name

Post by *Dalai » 2019-02-25, 14:34 UTC

From TC help > Operation > User interface > Dialog box to change the whole button bar:
%O places the current filename without extension into the command line.
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
Power Member
Power Member
Posts: 2437
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: A Button for translate selected file name

Post by *Stefan2 » 2019-02-25, 15:55 UTC

drbeat wrote:
2019-02-25, 14:15 UTC
The problem is copy file names without extension, how can I do that?
Create a button

Command: cmd /c
Parameter: ECHO %O
Icon: e.g. "C:\windows\system32\cmd.exe" -or- "%Commander_Path%\WCMICONS.DLL"
Tooltip: Copy name of current selected file to clipboard w/o extension
[x] Run minimized

- - -

For to pass several names without extension to a third-party programm, use a batch or a script.

Here's how to create a batch:
MakeBAT plugin by Christian Ghisler
MakeBAT plugin by Christian Ghisler - a plugin to create batch files
Plugin zum Erzeugen von Batchdateien (*.bat) mit allen markierten Dateien,


1. Unzip the makebat.wcx to the Totalcmd directory
2. In Total Commander, choose Configuration - Options
3. Open the 'Packer' page
4. Click 'Configure packer extension WCXs'
5. type 'bat' as the extension (without the single quotes)
6. Click 'new type', and select the makebat.wcx
7. Click OK

Read the "install.txt"

Useful tip that is not in README:
if your string starts and ends with a quote as in
"c:\pgm files\tc\some.exe" %N "C:\docs & setngs\"
you need to double up on the first and last quotes
""c:\pgm files\tc\some.exe" %N "C:\docs & setngs\""
due to the WindowsTM API may removes outer quotes on strings on writing/reading.

Also note that some called third-party tool may interpret
the trailing __\"__ as like "escape the quote as to remove them".

- Select wanted files
(here for example from TCs LANGUAGE-folder:

- Call pack dialog Alt+F5
- choose as "packer" the 'bat' from the drop-down list
- click [OK]

- In dialog box enter wanted command line, like: ECHO %O
(right click a button on TCs buttonbar, click Change...,
click [Help] to read more about variables like "%O")
- click [OK]

- Find in other panel a new textfile "<folder name>.bat"
(for our example: "LANGUAGE.BAT" with content:

Now open that text file
- adjust the command lines if need
(read the instructions of the called application what it needs as command)
- add on top as first line: @ECHO OFF
- add as last line: PAUSE
So you get:

Now your batch is ready to be started

Here a VBScript to read all selected files, drop the extension and call the external application (< your part to add)

Code: Select all

'//   VB-Script for Total Commander.
'//   Name   :   _ForEachSelFileDo_CallThirdpartyprogramWithoutExtension.vbs
'//   Author :   Stefan, 2019-02-25, v00.1
'//   Found at: https://ghisler.ch/board/viewtopic.php?p=351991#p351991
'//   Purpose:   Call external third-party program and pass selected file names.
'//              ToDo:
'//              Add your code below between the two '###-lines
'//   To use, create an button or user defined command (usercmd.ini)" 
'//   Command:     "D:\rive\path to\TotalCmd\Scrips\this.vbs"  or best "%Commander_Path%\Scripts\this.vbs"
'//   Parameter:   "%L"
'//                (Use the quotes as shown too for both cmd and param!)
'//			In button dialog press F1-key to read more: %L, %l, %F, %f, %D, %d, %WL, %WF, %UL, %UF
'//			 create a list file with the names of the selected files and directories,...
'//   Startpath:   <empty>
'//   Icon:        e.g. C:\windows\System32\WScript.exe -or- "%Commander_Path%\WCMICONS.DLL"
'//   Tooltip:     e.g.: _ForEachSelFileDo_ call

On Error Resume Next


If Wscript.arguments.Count < 1 Then 
	MsgBox "Parameter missed. Script quits here.",,"TC script error"
	sTCtempList = Wscript.arguments.Item(0) ' The TC temp file due to the "%L"-parameter.
End If

Set FSO = CreateObject("Scripting.FileSystemObject")
SET WSO	= CreateObject("WScript.Shell")
If  FSO.FileExists(sTCtempList) Then
    iFileCount = 0
    Set oTextStream = FSO.OpenTextFile(sTCtempList,1)
    Do Until oTextStream.AtEndOfStream
        iFileCount = iFileCount + 1
		sFullName = oTextStream.ReadLine		'//Ex: "X:\Backup\File.txt"
		If(Right(sFullName,1)= "\") Then 
			Set oItem 			= FSO.GetFolder(sFullName)
			Set oItem 			= FSO.GetFile(sFullName)
		End If        
        sName   = FSO.GetFileName(oItem)
        sBase   = FSO.GetBaseName(oItem)
        sExte   = FSO.GetExtensionName(oItem)
		sDrive  = FSO.GetDriveName(oItem)
		sPath   = oItem.ParentFolder
		aPathParts = split(sPath, "\")
		iUBound = UBound(aPathParts)
							  sParentFolder1 = aPathParts(iUBound)
		If (iUBound > 0) Then sParentFolder2 = aPathParts(iUBound -1)
		If (iUBound > 1) Then sParentFolder3 = aPathParts(iUBound -2)
		If (iUBound > 0) Then sTopFolder1  	 = aPathParts(1)
		If (iUBound > 1) Then sTopFolder2 	 = aPathParts(2)
		If (iUBound > 2) Then sTopFolder3 	 = aPathParts(3)

        '//The purpose of this script (do work here):
        IF(ShowMessage) Then
			'MB = MsgBox(prompt[, buttons 1vbOKCancel 3vbYesNoCancel vbDefaultButton1 vbQuestion vb-Modal][, title]) 
			MB = MsgBox("Current file: " &vbLF&""""& sFullName & vbLF _
				& "Thas is: " & sBase & """ with Extension: """ & sExte &"""" _
				& vbLF&vbLF&"Continue with next file?", VBYesNo+vbQuestion,"Total Commander VBScript")
			 If (MB = vbNo) Then WScript.Quit 
		End IF '(debug) Then
        'WSO.Run <here the command line of your third-party program....
        'WSO.Run strCommand [,intWindowStyle 0=Hide 1=Activate 2=mini 3=maxi ...] [,bWaitTillFinish? True/False]
        'WSO.Run "%COMSPEC% /k xcacls """ & sParentFolder1 & """ /E /G Domain\User:F"
        'WSO.Run "WMplayer ""C:\Users\Public\Videos\Sample Videos\Wildlife""",1,False
        'WSO.Run str7z & " a -t7z -mx9 -r -y " & strArchive & " " & vSource, 0, True

		'//copy ONE name to clipboard:
        'wso.run "cmd /c ECHO " & sBase & " |clip", 0, true
        '//collect ALL names for to copy to clipboard later:
		strClipboardContent = strClipboardContent & sBase & vbCRLF



    MsgBox strClipboardContent
	SetClip strClipboardContent

    MsgBox "All done"
    MsgBox "Input file sTCtempList not found.",,"Total Commander VBScript - ERROR"
End If
Function SetClip(strText)
    Set oExecCMD = WSO.Exec("clip")
	Set oExecCMDIn = oExecCMD.stdIn
	oExecCMDIn.WriteLine strText
End Function 'SetClip(strText)
'///////////////////////////////////////////////////////////////////////////////// THE END


Post Reply