Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am looking for assistance as I have searched unsuccessfully for a script which will run through a directory and delete the first line of text in every txt file. I just can't figure out the coding to undertake this.Grateful thanks to anyone who can help!
Dalgetty

@echo off > newfile & setLocal enableDELAYedexpansion
for /f "tokens=* delims= " %%a in ('dir/b/a-d *.txt') do (
type nul > newfile
for /f "tokens=* skip=1 delims= " %%i in (%%a) do (
>> newfile echo %%i
)
copy newfile %%a
)
=====================================
Helping others achieve escape felicityM2

Hi M2,
This is brilliant! However I omitted to mention that I need the output for each file in the directory to go a separate newfile eg newfile1, newfile2, newfile3 etc. Is that within the capacity of a CMD script?
Ever so grateful!
Dalgetty

![]() |
wont do anything
|
Where can I find Whistler...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |