How to send multiple files to 'Xrecode' application?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
seamoonz
Junior Member
Junior Member
Posts: 14
Joined: 2011-03-19, 15:07 UTC

How to send multiple files to 'Xrecode' application?

Post by *seamoonz »

I've created a button to quickly add files from TC. But it can't add more than one selected file to Xrecode

Xrecode parameters
http://xrecode.com/cmdline.txt

his doesn't work:

Code: Select all

/input %P%S /sameassource /dest mp3 /of /vbr /VBRMin 11 /VBRMax 14 /recycle
Works only for first file:

Code: Select all

/input %V /sameassource /dest mp3 /of /vbr /VBRMin 11 /VBRMax 14 /recycle
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Execute application For Each selected file Do run script bat

Post by *Stefan2 »

Perhaps Xrecode gets only one filespec as parameter.
Either one full file path, or extension filter like *.mp3

/input - input file name (supports wildcards * ?). Several file masks can be specified, e.g. /input "c:\input\*.mp3;*.wav;*.flac"


So try to call Xrecode for each selected file by utilizing a Batch or Script.

For TC Button use "D:\rive\path\to\BatchScript.ext" as COMMAND
and "%L" or %P%S as PARAMETER, depending on the batch/script you use.

COMMAND: "D:\rive\path\to\BatchScript.ext"
PARAMETER: "%L"
PARAMETER: %P%S



For better understanding
- right click an button in the button bar
- chose "Change..."
- in that dialog press F1 key, scroll down and read for %P%N and such




Example batch/scripts are for example (many more can be found in the forum):

This are examples only, ask for more detailed help for your purpose.
REM http://ghisler.ch/board/viewtopic.php?t=36880
REM MVV Power Member Posted: Fri May 17, 2013 7:56

@echo off
rem Processing of %P%S
:loop_next
if -%1==- goto loop_end
echo Do something with "%~1"
REM Xrecode /input "%~1" /sameassource /dest mp3 /of /vbr /VBRMin 11 /VBRMax 14 /recycle
shift
goto loop_next
:loop_end
pause

Code: Select all

REM http://ghisler.ch/board/viewtopic.php?t=41256
REM ZoSTeR  Power Member Posted: Fri Oct 17, 2014 14:10
REM TC-Button with Parameter "%F" "%P" "%T"

@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 (
   
   rem ============== Insert your custom commands here ==============
   
   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
   
   rem ==============================================================
)
echo %concat%
echo !concat!
pause
cls
endlocal
Hacker Power Member Posted:


RunOnAllcores.ahk "%L" "pngcrush -ow -oldtimestamp -rem alla ""#####"""

http://ghisler.ch/board/viewtopic.php?t=31528

HTH
Roman


ForEachFileDo01 - simple.ahk

Code: Select all

;//   D E S C R I P T I O N:
;// AHK-script for Total Commander to :
;// Stefan, v00.1, 2015-05-08
;// Forum:
;=====================================================================================
;// AutoHotkey (AHK) is a free, open-source macro-creation and automation software. (http://ahkscript.org/)
;// Download the executable: http://ahkscript.org/download/  (portable zip, Unicode 32-bit, is just fine)
;// Unpack the archive, e.g. to  "TC-Folder\Tools\AHK" or take care on the path yourself.
;// More Resources / Help / AutoHotkey Community: http://ahkscript.org/#Resources_at_bottom
;// The AutoHotkey Foundation, Our History: http://ahkscript.org/foundation/history.html
;// Note: I still use the old v1.0 version (AutoHotkey1.0.48.03 - May 3, 2009) because it's much smaller.
;//       So it could be that something doesn't work for you, if you use other version then I had used.
;//  ------------------------------------------------------------------------------------
;// Integration into Total Commander:
;//     Modify this script as you want for one single purpose.
;//     Save this script with a new name, like DoX.ahk ('.ahk' is mandatory)
;//     Create a new usercmd.ini entry, like 
;//         [em_RunAHK_DoX]
;//         Cmd=%Commander_Path%\Tools\AHK\AutoHotkey.exe
;//         Para=%Commander_Path%\Tools\AHK\DoX.ahk <perhaps an TC parameter here like "`%L"> SHOW
;//            (see Help > Operation > User interface > Button bar > click on "Dialog box to change")
;//     Use quoted "`%L" as first parameter for a list with paths and file names: C:\path\filename.ext
;//     Use quoted "`%F" as first parameter for a list with file names only: filename.ext
;//     (See TC help for more: search for "Configuration - Change button bar")
;//     Use "SHOW" as second TC parameter to see an dialog, instead of just executing.
;//     Use this new entry as button command "em_RunAHK_DoX", or assign a keyboard shortcut to it (Configuration > Misc.).
;//     Also, you can use this 'cmd' and 'para' commands on an button directly. (right click the button bar)
;=====================================================================================
;=====================================================================================
;===================================================================================== AHK Basics
;//  S C R I P T    S E T T I N G S:
#SingleInstance force    ;Skips the dialog box and replaces the old instance automatically
;#NoTrayIcon              ;if you don't want a tray icon for this AutoHotkey program.
#NoEnv                   ;Recommended for performance and compatibility with future AutoHotkey releases.
If (%0% > 0)
{
    ;If you call this script from within TC and use one of the `%L, `%F,... parameters,
    ;then TC will create a temporary text file with a list of the selected files and folders.
    ;We gonna use this text file and parse it line by line to modify it as you like.
    vTCtempfile=%1%
    ;MsgBox We are using:`n%vTCtempfile%
    ;Run, notepad %vTCtempfile%
} else {
    MsgBox TC file list parameter "`%L" is missing, see TC help for more (Search for: Configuration - Change button bar).
    ;ExitApp
}
;===================================================================================== The CODE:
;//Process the file list, line by line:
Loop, Read, %vTCtempfile%
{
    vCurrTempFileLine = %A_LoopReadLine%
    ;MsgBox Curr line is:`n%vCurrTempFileLine%
  
  
    ;Run, Target [, WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID]   
    RunWait, " ""Xrecode /input ""%vCurrTempFileLine%"" /sameassource /dest mp3 /of /vbr /VBRMin 11 /VBRMax 14 /recycle"" "
  
     
    ;//collect each processed line into the output variable:
    ;vOut += %vTEMP%`r`n
} ; next line
;// All lines done.

;===================================================================================== Result / Output:
;===== Work with our fabricated result
;// PASTE RESULT TO CLIPBOARD:
;Clipboard = %vOut%
;msgbox %vOut%
ExitApp



#PowerShell: ForEach in %L do copy to...
PowerShell -noexit
TYPE "%L" | ForEach{ copy $_ -recurse F:\tmp}

VBScript
_ForEachSelFileDo2016.0228.vbs

Code: Select all

'// ===========================================================
'// VBScript for Total Commander, by Stefan
'// _ForEachSelFileDo.vbs, Version 16.0228, 2016-02-28
'// Forum: 
'// Purpose: 
'//     Example: 
'//
'// TC Button:
'//         CMD:   "D:\rive\path\to\this\script.vbs"
'//         PARAM: "%L"
'// USAGE: Scroll down to "UserWorkHere" and add your code.
'//        Select your files, execute this script... done.
'// ===========================================================
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO = CreateObject("WScript.Shell")
Set NET = CreateObject("WScript.Network")
Set FSO  = CreateObject("Scripting.FileSystemObject")
Set WSO  = Wscript.CreateObject("WScript.Shell")
Set NET  = Wscript.CreateObject("WScript.Network")
Set ARGs = WScript.Arguments
ScriptPath     = FSO.GetParentFolderName(WScript.ScriptFullName)
TCPath         = WSO.ExpandEnvironmentStrings("%Commander_Path%")
PrgFiles       = WSO.ExpandEnvironmentStrings("%ProgramFiles%")
PrgFiles86     = WSO.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
PrgFilesCommon = WSO.ExpandEnvironmentStrings("%CommonProgramFiles%")
SystemRoot     = WSO.ExpandEnvironmentStrings("%SystemRoot%")
SystemDrive    = WSO.ExpandEnvironmentStrings("%SystemDrive%")
HostName       = WSO.ExpandEnvironmentStrings("%ComputerName%")
UserName       = WSO.Environment("process") ("username")
UserProfile    = WSO.ExpandEnvironmentStrings("%USERPROFILE%") 
AllUsersProf   = WSO.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
UserTEMP       = WSO.ExpandEnvironmentStrings("%tmp%") 
SysTEMP        = SystemRoot & "\Temp"  'SystemDrive & "\Temp"
vbQuote        = chr(34)
Const ForReading = 1, ForWriting = 2, ForAppending = 8

'// =========================================================== Read TCs temp list:
sTCtempList = Wscript.arguments.Item(0) ' The TC temp file due the "%L"
If  FSO.FileExists(sTCtempList) Then
    Set oTextStream = FSO.OpenTextFile(sTCtempList,ForReading) 
    sFileContent = oTextStream.ReadAll
    oTextStream.Close
    aLineArray = split(sFileContent,vbCRLF)
    iAllFileSCount = UBound(aLineArray) 
    iPaddingAmount = len(iAllFileSCount)
    '// =================== Get first line to do basic things one time only:
    sFirstLine = aLineArray(0)
    iFilesCount = 0
    If(Right(sFirstLine,1)= "\") Then IsFolder = True Else IsFolder = False
    If(IsFolder) Then
      Set oItem	= FSO.GetFolder(sFirstLine)
    Else
      Set oItem	= FSO.GetFile(sFirstLine)
    End If
    sDrive  			= FSO.GetDriveName(oItem)	'//Ex: "X:"
    sPath   			= oItem.ParentFolder		  '//Ex: "X:\Backup"
    aPathParts 		= split(sPath, "\")
    iUBound 			= UBound(aPathParts)
    sParentFolder1 = aPathParts(iUBound)		'//Ex: "Backup"
    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)
    'MsgBox sDrive&LF&sPath&LF&iUBound&LF&sParentFolder1&LF&sParentFolder2&LF&sTopFolder2
    '// =================== For each line in TCs temp list, Do your work:
    For i=0 To  UBound(aLineArray) -1
      datStartTime = Now()
      iFilesCount  = iFilesCount + 1
      sFullName    = aLineArray(i)
      sName        = FSO.GetFileName(oItem)		    '//Ex: "File.txt"
      sBase        = FSO.GetBaseName(oItem)		    '//Ex: "File"
      sExte        = FSO.GetExtensionName(oItem)	'//Ex: "txt"
      sSize        = oItem.Size
      sVers        = FSO.GetFileVersion(oItem)
      sCreated     = oItem.DateCreated
      sAccessed    = oItem.DateLastAccessed
      sModified    = oItem.DateLastModified
      '// ################################################################## UserWorkHere:
      '// DO YOUR WORK HERE (For each line in TCs temp list):
      
       msg "File No.: " & iFilesCount & " of " & iAllFileSCount & " = " & sFullName
      
      'WSO.Run strCommand [,intWindowStyle 0=Hide 1=Activate 2=mini 3=maxi ...] [,bWaitTillFinish? True/False]
      WSO.Run "Xrecode /input " & vbQuote & sFullName & vbQuote & " /sameassource /dest mp3 /of /vbr /VBRMin 11 /VBRMax 14 /recycle",1,true
      
      
      
      '// DO YOUR WORK ABOVE.
      '// ##################################################################
    Next
Else
    MsgBox "E R R O R:  Input file 'sTCtempList' (%L)  not found OR no selection done before.",,"TCs-VBScript - ERROR"
    ShowUsageMsg
    WScript.Quit
End If
'// =========================================================== Output the result:
sOUT = Left(sOUT, Len(sOUT)-2) '//removing trailing line break:
' SetClipboard sTemp & vbCR & sOUT ' test output
'SetClipboard sOUT
'// =========================================================== HELPER FUNCTIONs
Sub msg(str)
	ret = MsgBox( str  & vbCRLF & vbCRLF & vbCRLF & vbCRLF & vbCRLF & "Continue script?", vbOKCancel + vbQuestion , "TCs-VBScript - Debug")
	if(ret = vbCancel) then WScript.Quit
End Sub 'msg(str)
Function ShowUsageMsg
	On Error Resume Next
	Dim UsageMsg
	UsageMsg = "Visual Basic Script (VBS) for use with Total Commander (TC)" & vbCRLF & vbCRLF
	UsageMsg = UsageMsg & "USAGE:" & vbCRLF
	UsageMsg = UsageMsg & "Create an button (or a user command) with this settings:" & vbCRLF
	UsageMsg = UsageMsg & "COMMAND:" & vbTab & vbQuote & "D:\rive\path\to\this.VBS"  & vbQuote & vbCRLF
	UsageMsg = UsageMsg & "(Portable cmd:" & vbTab & vbQuote & "%Commander_Path%\MyTools\this.VBS"  & vbQuote & ")" & vbCRLF
	UsageMsg = UsageMsg & "PARAMETER:" & vbTab  & vbQuote & "%L" & vbQuote & vbTab & " (read TCs Help for more)" & vbCRLF 
	UsageMsg = UsageMsg & "Startpath:" & vbTab & vbTab & "<empty>" & vbCRLF 
	UsageMsg = UsageMsg & "ICON file:" & vbTab & vbTab & vbQuote & "C:\Windows\System32\WScript.exe" & vbQuote & vbCRLF 
	UsageMsg = UsageMsg & "Tooltip:" & vbTab & vbTab & "For Each selected file do VBS" & vbCRLF
	UsageMsg = UsageMsg & "Set:" & vbTab & vbTab & "[X] Run minimized" & vbCRLF & vbCRLF
	UsageMsg = UsageMsg & "Press F1-key while in button dialog for more help." & vbCRLF & vbCRLF
	UsageMsg = UsageMsg & "Next, select a few files and call this script...." & vbCRLF
	MsgBoX UsageMsg,, "TCs-VBScript - Help"

	' %L will create an temporary file like "C:\Users\myusername\AppData\Local\Temp\CMDB034.tmp" which holds the list of the selected files.
	'       %P als beliebig oft erlaubter Parameter bewirkt, dass der Pfad des Quellverzeichnisses in die Kommandozeile gestellt wird (inkl. \ am Ende).
	'       %N als ebenfalls beliebig oft erlaubter Parameter bewirkt, dass der aktuelle Dateiname (umgeben von einer gestrichelten Box) 
	'       %T (Target) fügt den aktuellen Zielpfad ein.
	'       %M fügt den im Zielverzeichnis gewählten Dateinamen ein.
	'       %O fügt den aktuellen Dateinamen ohne Erweiterung in die Kommandozeile ein.
	'       %E fügt die aktuelle Dateierweiterung (ohne Punkt) in die Kommandozeile ein. 
	'       
	'       %L Lange Dateinamen inkl. kompletten Pfads, z.B. c:\Eigene Dateien\langer Name.txt
	'       %l (kleines L) Kurze Dateinamen inkl. kompletten Pfads, z.B. C:\EIGENE~1\LANGER~1.TXT
	'       %F Lange Dateinamen ohne Pfad, z.B. langer Name.txt
	'       %f Kurze Dateinamen ohne Pfad, z.B. LANGER~1.TXT
	'       %D Kurze Dateinamen inkl. kompletten Pfads, aber Umlaute im DOS-Zeichensatz
	'       %d Kurze Dateinamen ohne Pfad, aber Umlaute im DOS-Zeichensatz
	'       %UL, %UF wie %L und %F, aber mit UTF-8-Unicode-Listendatei (mit Byteordermarker)
	'       %WL, %WF wie %L und %F, aber mit UTF-16-Unicode-Listendatei (mit Byteordermarker)

End Function 'ShowUsageMsg
Function SetClipboard(stringToClipboard)
    On Error Resume Next
    Set oIE = CreateObject("InternetExplorer.Application")
    oIE.Navigate("about:blank")
    oIE.document.parentwindow.clipboardData.SetData "text", stringToClipboard
    oIE.Quit : Set oIE = Nothing
End Function
Function GetClipboard
	On Error Resume Next
	Dim oIE
	Set oIE = CreateObject("InternetExplorer.Application")
	oIE.Navigate("about:blank")
	GetClipboard = oIE.document.parentwindow.clipboardData.GetData ("text")
	oIE.Quit : Set oIE = Nothing
End Function 'GetClipboard
Function GetTimestamp
	On Error Resume Next
  N = Now
  WN = WeekdayName( Weekday(N), true)
  DD = "-"
  Da = Year(N) & DD & Right("00" & Month(N), 2) & DD & Right("00" & Day(N), 2)
  Ti = Right("00" & Hour(N), 2) & Right("00" & Minute(N), 2) & Second(N)
	'GetTimestamp = Da & ", " & WN & "_" & Ti
	GetTimestamp = Da & "_" & Ti
End Function 'GetTimestamp
'// =========================================================== Command store:
'WSO.SpecialFolders("Programs")  AllUsersDesktop AllUsersStartMenu AllUsersPrograms AllUsersStartup Desktop
'Favorites Fonts MyDocuments NetHood PrintHood Programs  Recent SendTo StartMenu Startup Templates SIEHE auch FSO.GetSpecialFolder

'IB = InputBox(prompt[, title][, default] ,Xpos,Ypos,HelpFile location, Context in the help file) 
'  If (IB = "") Then CANCEL pressed ELSE OK or ENTER pressed, 'IsEmpty (returns True when VAR has been declared but not initialized), 
'   IsNull (if the expression is Null), IsNumeric (if the expression is a number)

'MB = MsgBox(prompt[, buttons 1vbOKCancel 3vbYesNoCancel vbDefaultButton1 vbQuestion vb-Modal][, title]) 
' If (MB = vbCancel) Then WScript.Quit 
'  MsgBox Return Values: VBOK 1 / VBCancel 2 / VBAbort 3 / VBRetry 4 / VBIgnore 5 / VBYes 6 / VBNo 7
'  MsgBox Button Constants: VBOKOnly 0 / VBOKCancel 1 / VBAbortRetryIgnore 2 / VBYesNoCancel 3 / VBYesNo 4 / VBRetryCancel 5
'    VBCritical 16 / VBQuestion 32 / VBExclamation 48 / VBInformation 64 / VBDefaultButton1 0 / db2=256 / db3=512 / db4=768
'    VBApplicationModal 0 respond before allowing continue / VBSystemModal 4096 Causes suspension of ALL applications 


'WSO.Run strCommand [,intWindowStyle 0=Hide 1=Activate 2=mini 3=maxi ...] [,bWaitTillFinish? True/False]
'intRunError = WSO.Run("%COMSPEC% /c Echo Y| cacls "_& strHomeFolder & " /t /c /g Administrators:f "_& strUser & ":F", 2, True)
		 'If intRunError <> 0 Then Wscript.Echo "Error

'// =========================================================== Results examples:
'// Example RESULTs:
'// =========================================================== END



 
seamoonz
Junior Member
Junior Member
Posts: 14
Joined: 2011-03-19, 15:07 UTC

Post by *seamoonz »

Xrecode designed to work with multiple files, this do the job but path should be specified, how to make path universal?

Code: Select all

/input  "c:\Timmy Regisford - At The Club [2010 Tribe]\*.flac" /sameassource /dest mp3 /of /vbr /VBRMin 11 /VBRMax 14  /recycle
User avatar
Ovg
Power Member
Power Member
Posts: 755
Joined: 2014-01-06, 16:26 UTC

Post by *Ovg »

2seamoonz

try /input %P*.%E, cursor should be on file with desired extension
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

seamoonz wrote: but path should be specified, how to make path universal?

In Button dialog press F1-key and read the help.


To put in the path of the current active panel, utilize TCs %P parameter:

%P causes the source path to be inserted into the command line, including a backslash (\) at the end.


COMMAND: Xrecode
PARAMETER: /input "%P*.flac" /sameassource /dest mp3 /of /vbr /VBRMin 11 /VBRMax 14 /recycle



Do you means something like this?
 
seamoonz
Junior Member
Junior Member
Posts: 14
Joined: 2011-03-19, 15:07 UTC

Post by *seamoonz »

Both solution worked fine. Thank you very much!
Post Reply