Windows 7 batch file to copy text file

ive been struggling for 3 hours now

what im trying to do from a windows .bat file is

copy a text file to another text file, all lines except the first two

does anyone have an idea if this is actually possible ?


I think you my want to ask this question on StackOverflow, as it does not pertain to InfinityFree.

This answer (edited) uses VBA, but Windows can support that:

Dim a1 As String = "C:\tmp\casefile.txt"
Dim b1 As String = "C:\tmp\returnfile.txt"
Dim aa1 As IO.StreamReader = IO.File.OpenText(a1)
Dim bb1 As IO.StreamWriter = IO.File.AppendText(b1)

Dim rr00 As String = aa1.ReadLine()
Do Until aa1.Peek() = -2
   rr00 = aa1.ReadLine()

You can also do this with PowerShell (get all files and write line 3+ to a file in %temp%\files with the same name):

Get-ChildItem -File | ForEach-Object {
    $stream_reader = New-Object System.IO.StreamReader{$_.FullName}
    $FileName = $_.Name
    $line_number = 3
    while (($current_line =$stream_reader.ReadLine()) -ne $null) {
        "$current_line" | Out-File -FilePath $env:TEMP\files\$FileName -Append

thanks, the first place i tried was stack overflow

but after 20 mins of trying to fight their stupid ai blocking my question post i had to give up

its virtually impossible to post a question on that site

Although Stackoverflow might be a good option to ask your questions, it’s not very user-friendly.

Sure, you are able to ask questions and get answers for code you are struggling with, but 9 times out of then your post will get flagged, deleted, closed, or it will just not let you post.

Additionally, Stackoverflow is not very “new-user” friendly as every time you post a question and don’t provide exact detail they will “attack” you in the comments of your post. Other times it could be they will criticize your code instead of helping. An example would be: a user posted his HTML code and inside it, there was a table element; guess what, some user in the comments was saying table elements should only be used to show “tabular” data, and OP’s post was closed.

In conclusion, I say the Stackoverflow community has become very toxic and demandant on the topics you post.


it turns out i only need to remove the first line so after a few more hours of messing around in .bat file i came up with this

it works but it seems to be stripping “!” characters from the original text which github uses for image links etc

i have no clue why its doing that

rem --------------------------------------------------
rem  generate with new build number
rem --------------------------------------------------
echo Build %bbcProjectBuildBin%>..\
setLocal enableDelayedExpansion
set o=no
for /f "delims=¬" %%i in (..\ do (
  if "!o!"=="yes" echo %%i>>..\
  set o=yes
set o=
del /q ..\
ren ..\

this worked 100%

rem --------------------------------------------------
rem  update with new build number
rem --------------------------------------------------
echo Build %bbcProjectBuildBin%> ..\
for /f "skip=1 tokens=*" %%s in (..\ do (
	echo %%s>> ..\
del /q ..\
ren ..\

@wackyblackie I posted it here in informal because everyone here is so helpful and informal category says this


Yes, sorry! I was mistaken.


thats cool, it proves youre human :rofl:

but thanks , youre always so helpful


This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.