Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch expert needed file cannot be for looped because of first symbol  (Read 9237 times)

0 Members and 1 Guest are viewing this topic.

pamomil605

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    I'm having a bit of an issue in the link there is a text file and you will notice that first character is unknown symbol and after batch tries to for loop it only copies that first character and stops there.

    Is there a way to tell batch to continue or to warn him before that there is unknown symbol? or even delete it and proceed with the rest of file?

    Link to text file:
    https://easyupload.io/eknrri

    Script:

    Code: [Select]
        :: Turn echo off
        @echo off
       
        :: Enable extensions
        SETLOCAL EnableExtensions
        SETLOCAL EnableDelayedExpansion
       
        :: Set input file
        set "InputFile=index.txt"
       
        :: Set output file
        set "OutputFile=output.txt"
     
        :: Check if output file exits if it does delete it
        If Exist "%OutputFile%" Del "%OutputFile%"
       
        :: Loop through input file
        for /F "tokens=* delims=" %%A in ('Type "%InputFile%"') do (
            :: Set line equal to file text
            set line=%%A
       
            echo !line!
        )>>"%OutputFile%"