Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Sending filenames with directory aliases to external commands

May
12,845
164
@TRUENAME will help. Note that @TRUENAME quotes/unquotes filenames as necessary (and does not check for their existence)

I use several directory aliases. And I have the alias e=call u:\tpad.btm. The BTM creates files that don't exist (to avoid textpad's "Create...?" message box) but it did not (until today) handle directory aliases. Now it does. It's fairly simple.

Code:
REM TPAD.BTM
setlocal
set command=d:\textpad7\textpad.exe
do i=1 to %#
    set filename=%@truename[%[%i]]
    if not exist %filename touch /c /q %filename
    set command=%command %filename
enddo
start %command
 
Has @TRUENAME changed since version 27? It does not add or remove quotes for me.

Code:
TCC(27.01.24): C:\tcmd\ver27>echo %@truename[drop:file with spaces]
C:\users\jay\dropbox\file with spaces

I need to use @QUOTE.

Code:
TCC(27.01.24): C:\tcmd\ver27>echo %@quote[%@truename[drop:file with spaces]]
"C:\users\jay\dropbox\file with spaces"

TCC(27.01.24): C:\tcmd\ver27>echo %@quote[%@truename[drop:file_without_spaces]]
C:\users\jay\dropbox\file_without_spaces
 
I’m a little confused here. Why are you using the



do i=1 to %#



If there are multiple command line parameters, you would perform the “touch” command for each one, but you will only launch textpad for the last command line parameter.



Why not just use %1 and forget the do loop?
 
I am launching textpad only once, outside the DO loop. The DO loop is to expand directory aliases in any file name on the command line that needs it.
 
I don’t see any need for the do loop, but perhaps I am failing to understand what you’re trying to do.



And I have to agree with Jay Sage, the TRUENAME is not adding quotes for me. From the help page:



If filename is quoted, the returned filename will also be quoted (if necessary)



This works for me, no do loop, using my editor of choice, and adding the @QUOTE





@echo off setlocal set command=c:\vim\vim90\gvim.exe set filename=%@truename[%1] if not exist %@quote[%filename] touch /c /q %@quote[%filename] set command=%command %@quote[%filename] start %command

My version of TCC:

TCC 29.00.17 x64 Windows 11 [Version 10.0.22623.1245]

ON EDIT:
this will work:
set filename=long file name
set filename=%@truename["%filename"]

this won't work:
set filename=long file name
set filename=%@truename[longfilename]
 
When I say e dt:\foo.txt plug:\plugin.txt docs:\sample.txt I want nonexistent files to be created and then the following command executed.

Code:
d:\textpad7\textpad.exe C:\Users\vefatica\Desktop\foo.txt D:\data\tccplugins\plugin.txt C:\users\vefatica\documents\sample.txt

You are right (and I was wrong) about @TRUENAME and quotes.
 
Ah ha! That's the part I failed to understand, you want to open multiple files in your text editor. Not something I normally find any need to do, so I wasn't expecting it.
 
Back
Top