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
[Button bar] %N and %M behaves differently
Moderators: Hacker, petermad, Stefan2, white
- ghisler(Author)
- Site Admin
- Posts: 50650
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Thanks for Your kind answer!ghisler(Author) wrote:Could you try %O%E (combined) instead of %N?
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
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.