Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
senonolo
- Posts: 1
- Joined: 09 Jun 2020 03:13
#1
Post
by senonolo » 09 Jun 2020 03:27
Hi
I'm trying to remove the first 67 characters and here's what I've got so far:
Code: Select all
@echo off & setlocal enabledelayedexpansion
set "txt=*.txt"
set N=
for /f "tokens=* delims= " %%a in ('type "!txt!"') do (
set /a N+=1
if !N! lss 3 set S=!S!%%a
)
> Result.txt echo.!S:~67!
for /f "tokens=* skip=2 delims= " %%a in ('type "!txt!"') do (
echo.%%a
) >> Result.txt
goto :eof
It's work as expected only for one file.
I need it to loop the code for all files in a folder.
Can someone help me out?
Thanks!
-
ShadowThief
- Expert
- Posts: 1160
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#2
Post
by ShadowThief » 09 Jun 2020 09:44
> overwrites the file
>> appends to the end of the file
-
penpen
- Expert
- Posts: 1991
- Joined: 23 Jun 2013 06:15
- Location: Germany
#3
Post
by penpen » 15 Jun 2020 02:37
You might want to use only one file per loop and add an outer loop (to not mix up files).
This might help you (but is untested):
Code: Select all
@echo off & setlocal enabledelayedexpansion
set "txt=*.txt"
:: the following line will delete the content of "Result.txt", if you don't want that delete it
>"Result.txt" rem:
for %%A in ("%txt%") do(
set N=
for /f "tokens=* delims= " %%a in ('type "%%~A"') do (
set /a N+=1
if !N! lss 3 set S=!S!%%a
)
>>"Result.txt" echo.!S:~67!
for /f "tokens=* skip=2 delims= " %%a in ('type "%%~A"') do (
echo.%%a
) >>"Result.txt"
)
goto :eof
penpen