TCC has much more elegant ways for usebackq. What ways?

Oct 20, 2017
31
0
Netherlands
Take Command / TCC Help v.24 page 410:
"usebackq : Duplicates the awkward CMD syntax. A back quoted string is executed as a command;
a single quoted string is a literal string; and double quotes quote filenames in the file set. We don't
recommend usebackq for batch files written for TCC, as TCC has much more elegant ways of doing
the same things."

I’m looking in the wrong places and I can't find "much more elegant ways".
Please, give me direction or examples.

Thanks
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,447
88
Albuquerque, NM
prospero.unm.edu
Also: If you only want one line of a command's output, the @EXECSTR function is the neat way. If you want to process all lines of a command's output, you can pipe to a subroutine or an alias.
 

samintz

Scott Mintz
May 20, 2008
1,501
16
Solon, OH, USA
I use DO /P all the time.
Code:
do f in /p some_command (echo %f)

In the above example, %f represents an entire output line, not just a token like FOR.
 
Oct 20, 2017
31
0
Netherlands
Hi Charles & Scott,

I use this working line of code :

"for /f "delims=" "usebackq" %a in (`MediaInfo.exe --Output=Video;%%Duration/String%% "%i"`) do @set duration=%a"

The variable "duration" contains one line of output from the external programm MEDIAINFO.EXE.

How should this line of code work with @EXECSTR or DO /P?

Thanks
 
May 20, 2008
11,388
99
Syracuse, NY, USA
Not knowing the syntax for mediainfo.exe, I'd start here.

Code:
do a in /p mediainfo.exe --Output=Video;%%Duration/String%% %i (@set duration=%a)
 
May 20, 2008
11,388
99
Syracuse, NY, USA
Almost! Mediainfo.exe seems OK but wrapping it in DO has an anomaly.

Code:
v:\> MediaInfo.exe --OutPut=Video;%%Duration/String%% FlickAnimation.avi
3 s 933 ms

v:\> do a in /p MediaInfo.exe --OutPut=Video;%%Duration/String%% FlickAnimation.avi (echo %a)
/String

Here's a workaround. But why is it necessary?

Code:
v:\> do a in /p MediaInfo.exe --OutPut=Video;%%%%Duration/String%%%% FlickAnimation.avi (echo %a)
3 s 933 ms

For dumbenis, change my suggestion to

Code:
do a in /p mediainfo.exe --Output=Video;%%%%Duration/String%%%% %i (@set duration=%a)

And here is how @EXECSTR works.

Code:
v:\> set duration=%@execstr[MediaInfo.exe --OutPut=Video;%%%%Duration/String%%%% FlickAnimation.avi]

v:\> echo %duration
3 s 933 ms

So, dumbenis, instead of a FOR loop or DO loop you could do this.
Code:
set duration=%@execstr[MediaInfo.exe --OutPut=Video;%%%%Duration/String%%%% %i]
 

samintz

Scott Mintz
May 20, 2008
1,501
16
Solon, OH, USA
Commands that require percents are always going to be problematic to the parser. In the simplest case they can be doubled or escaped. But nested commands go through the parser more than once and might require multiple doublings.
 
Similar threads
Thread starter Title Forum Replies Date
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
D Pasting Unicode data has different behavior on TCC and CMD Support 2
C COMSPEC constantly reset to TCC.EXE Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
C How to? starting TCC/TCMD v25 Support 2
CWBillow TCC and TCMD in Powershell Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
L FTYPE in TCC, less quirky than in cmd.exe Support 3
V Set path permanently from within TCC? Support 3
DrusTheAxe Runaway TCC.exception.log filling drive Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
Joe Caverly tcc.exception.log Support 3
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
vefatica SCRIPT ... TCC disappears Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
Jesse Heines Access Denied errors in TCC 27 Support 9
fpefpe How to? tcc inifile (%_ininame) Support 3
M How to? Black TCC Prompt Support 2
D Differences between TCC and CMD with COPY /b Support 4
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
Jay Sage Extra TCC Tasks Support 6
vefatica Can I turn off the minimize to tray mechanism in TCC? Support 5
N Command execution slows down in TCC Prompt after a while Support 6
R Upgrade TCMD 19 to TCC 26 Support 1
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
samintz How to? Is this doable in TCC? Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT 26.02.41 Uploaded Support 0
D TCC tab detaching & restarting Support 3
Ó Recent git output not shown on TCC Support 1
P Kill all other instances of tcc from a btm batch file Support 2
L Using TCC.exe through an SSH connection Support 3
M TCC color issue in ConEmu Support 4
Alpengreis UTF-8 problem in TCC related to Python Support 7
Alpengreis Python support for 3.8.3 in TCC v26.x? Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT 26.01.40 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 26.0.37 Uploaded Support 0
vefatica TCC waits for Office apps Support 4
Joe Caverly .BAT works in TCC-RT 25, but not in TCC-RT 26 Support 4
M Strange error messages from TCC in FTP copy Support 7
Kachupp Documentation tcc-rt versions Support 1
V Comments from a first-time user (TCC 26) Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT 26.0.28 Support 0
C TCC 26 BATCOMP BTM problems? Support 5
E TCC/CMD difference Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT Public Beta RC2 Support 0

Similar threads