Batch TAB delimit also removes T, A and B characters on ECHO

I have about 300 files that need to be parsed, which are delimited by tabs. The code I am using below (unfinished):

for /r C:\mywork2\MAX\ %%f in (*) do (
    for /f "delims=TAB" %%i in (%%f) do (
        for %%u in (%%i) do (
            ECHO %%u
        )
    )
    pause
)

      

It seems to work fine, except when the field starts with T, A or B, does ECHO remove that character? those. Taxidea_taxus

becomes axidea_taxus

. Is this a bug or can I work around it? It should be noted that using <TAB>

it has the same effect.

+3


source to share


1 answer


When you specify delims=TAB

, the processor uses literally T

, A

and B

as separators. To use the Tab character, you enter a literal tab (which will appear as a space in the script).

Try the following:



REM Set a variable to the <TAB> character.
REM Make sure you editor doesn't replace Tabs with spaces.
REM Enter an actual <tab> in the SET statement below.
SET "TabChar=    "

for /r C:\mywork2\MAX\ %%f in (*) do (
    REM Parse with the tab character.
    for /f "delims=%TabChar%" %%i in (%%f) do (
        for %%u in (%%i) do (
            ECHO %%u
        )
    )
    pause
)

      

+2


source







All Articles