using usebackq
Posted: 09 Jul 2014 11:24
in using usebackq, my attempt was to read the last token of each line, but tokens vary per line, so that's why I need to read the last token.
I interpreted that the command, usebackq, that it would reverse how the token will be processed / read, ie- as it will permit reading the last token.
usebackq - specifies that the new semantics are in force,
where a back quoted string is executed as a
command and a single quoted string is a
literal string command and allows the use of
double quotes to quote file names in
file-set.
What would be the correct code? if I can get some assistance, please / thank you! v/r Booga73
contents of mystring.txt
---------------------------------------------------
I interpreted that the command, usebackq, that it would reverse how the token will be processed / read, ie- as it will permit reading the last token.
usebackq - specifies that the new semantics are in force,
where a back quoted string is executed as a
command and a single quoted string is a
literal string command and allows the use of
double quotes to quote file names in
file-set.
What would be the correct code? if I can get some assistance, please / thank you! v/r Booga73
Code: Select all
@ECHO OFF
for /f "usebackq tokens=1 delims==" %%a in (c:\mystring.txt) do (
echo %%a >> c:\mystring.txt
)
contents of mystring.txt
---------------------------------------------------
SystemRoot system32 drivers 1394ohci.sys
C: Program Files CommonFiles ActivIdentity ac.sharedstore.exe
SystemRoot system32 drivers accelern.sys
SystemRoot system32 drivers Accelerometer.sys
system32 drivers ACPI.sys
SystemRoot system32 drivers acpipmi.sys
system32 drivers ADIHdAud.sys
%SystemRoot% system32 AEADISRV.EXE
SystemRoot system32 drivers afd.sys
SystemRoot system32 drivers agp440.sys