I got something I'd really like to do (but am unable to by myself), for which I'm convinced batch is the right tool. I do however have a very superficial knowledge about it, so even though I don't really like to ask for it, I'm hereby asking for some kind minds among this community (or beyond) to make a program or part of it for me :s
(for personal use only)
I'll certainly try to assemble together a program if components for it are shared, but I'm not expecting to be able to do so...
Among the research, I've found this link, which I guess is kinda useful...
The problem is as follows:
I have 47 folders. Each folder has a different number of txt files. In total, there 10633 txt files, their names are mostly random.
I need to add 1 new line of text to all the txt files, ideally at the end of the files, but it can be in the first line, if easier.
From trial 'n error, it seems that I need to insert the new line, after the 3rd line of each txt file (aka 4th line)...
I've tried this code here with the only success being no ctd
::@echo off
setlocal enabledelayedexpansion
set num = 0
for /r %%a in (*.txt) do (
::pause ::debug
for /f "tokens=*" %%a in (*.txt) do (
if !num! lss 3 echo %%a >>tmp.txt
if !num! equ 3 echo %%a >>tmp.txt
if !num! gtr 3 echo.blablabla >>tmp.txt
if !num! gtr 4 echo %%a >>tmp.txt
set /a num+=1
)
)
move /y tmp.txt *.txt
I can see that somethings not completely right with the code... since it doesn't completely work... , I just don't know what