[Button bar] %N and %M behaves differently

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
TrueY
Junior Member
Junior Member
Posts: 6
Joined: 2014-08-08, 08:59 UTC
Contact:

[Button bar] %N and %M behaves differently

Post by *TrueY »

Hi,

I faced to a small problem. I would like start a cygwin program from TC (v7.55), so I have created a new button and I passed %P, %N, %T, %M as arguments.

The problem I faced to was that %N behaves differently from how %M %P and %T behaves. If there is a space in the file name, then %N puts a quotation mark around, but others do not. So I set the parameters line like: "%P" %N "%T" "%M" (no quotation mark around %N). But if the selection is on "[..]" in both views then null strings are passed, so the batch file receives only 3 arguments: "<%P>" "<%T>" "". To compensate this I have to add quotation mark around %N, but then if the current selection contains a space the called program will receive extra quotation marks around. If the file is "xx xx.txt" then the passed argument becomes ""xx xx.txt"" for "%"N and "xx xx.txt" for "%M".

To work around this discrepancy I used to pass "%O" "%E" separately as they work like %M, %P, %T (some more hacking needs to be done to add '.' only if "%E" is not empty). So my life would be easier if I could use another special parameter instead of %N which behaves similarly to %M and others.

I assume %N behaves differently, because of some historical reason. Is there any way to make %N to work similarly to others? Or can I use other special parameter with the similar meaning?

Thank You in advance! TrueY
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Could you try %O%E (combined) instead of %N?
Author of Total Commander
https://www.ghisler.com
User avatar
TrueY
Junior Member
Junior Member
Posts: 6
Joined: 2014-08-08, 08:59 UTC
Contact:

Post by *TrueY »

ghisler(Author) wrote:Could you try %O%E (combined) instead of %N?
Thanks for Your kind answer!

Sure, I have tried this! But "%O%E" is not good as it does not put '.' in between. But "%O.%E" is also not good as it always puts an extra '.', even there is no extension at all. So if the file name is "aaa" then "%O.%E" become "aaa." instead of "aaa".

On the other hand I found another workaround to this issue! Unfortunately an extra batch file is needed:

Button's parameters in TC:
Command: c:\cygwin\Urxvt.bat
Parameters: "%P" ""%N"" "%T" "%M"
(Mind the extra quotation mark around %N!)

The Urxvt.bat file looks like this:

Code: Select all

set TC_SRCDIR=%~1
set TC_SRCFILE=%~2
set TC_DSTDIR=%~3
set TC_DSTFILE=%~4
REM Total Commander's %N behaves strange, so use as ""%N""
REM But then extra " has to be removed.
REM Works properly as Dos file cannot contain "
REM If %2 was not defined then TC_SRCFILE would set to "=, so check before chg
if NOT "%TC_SRCFILE%" == "" set TC_SRCFILE=%TC_SRCFILE:"=%
C:\cygwin\bin\run.exe urxvt.exe -pe tabbed -bg #000040 -fg #a0a000 -sl 5000 -geometry 83x45
It will set environment properly and in .bash_profile the I can see all parameters identically.

Of course the double quotation mark could be left out if %N was the last argument. But this trick sometimes cannot be used.

But this is only a workaround... It would be nice if there would be some other special parameter to handle the file name in the source directory identically to any other special arguments, so no extra batch hack would be necessary.
User avatar
TrueY
Junior Member
Junior Member
Posts: 6
Joined: 2014-08-08, 08:59 UTC
Contact:

Post by *TrueY »

May I ask to prepare some kind of solution for this problem? :idea: My suggestion is to implement a new special parameter for source file name (in addition to %N) which behaves identically to %M, %T and %P.

Or it is not relevant to anybody else? In that case I can live with the workaround... :wink:
Post Reply