Computer Hope
Microsoft => Microsoft DOS => Topic started by: GeorgeF on April 25, 2019, 06:24:23 AM
-
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 Advance
-
Manage 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