1.

Solve : Remove characters from a text file?

Answer»

Hi, been STRUGGLING to get this to work.

I have a txt file with 500 lines and growing, each LINE in the beginning has the text as the example below. I already have a batch file that joins 2 text files and one has K:\logs3\ and the other list just the files including folders.
ex. K:\logs3\test.txt

Its not a option to simple remove the FOLDER as that would create more issues and more work. Therefore is the a way to remove these charaters form the line - K:\logs3\ ?

Thanks in AdvanceManage to resolve my own problem but another issue has pop up concerning the same code.
The code below removes the FIRST 11 characters from a line in a text file. my issue now is to delete letters or characters in the middle of a text line. Example - I have C:\folder\doc - would like to remove "folder\ only and leave c:\ + doc.

think the issue might be over here - SET "line=!line:~0,11!"

Thanks in Advance



echo off &setlocal
(for /f "delims=" %%a in (list.txt) do (
    set "line=%%a"
    setlocal enabledelayedexpansion
    set "line=!line:~0,11!"
    echo(!line!
    endlocal
))>list.txt.new



Discussion

No Comment Found