# Use batch file to remove first line of text file



## Dalgetty

Hi - it's me again!

I didn't expect to be looking for assistance again so quickly but 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 now know, or think I know, how to get the batch file to run through each file but I just can't figure out the coding I require to perform the actual deletion of the first line. 

Grateful thanks to anyone who can help!

Dalgetty


----------



## TheOutcaste

Code:


@Echo Off
Set _Path=C:\Test Dir1
PushD %_Path%
For /F "Tokens=1 Delims=" %%a In ('Dir /A-D /B *.txt') Do (
Echo %%a
For /F "Usebackq Tokens=1 skip=1 Delims=" %%I In ("%%a") Do >>"%temp%\%%a" Echo.%%I
Move /Y "%temp%\%%a" .\
)
PopD

Set the path as needed, and change the extension if needed. **.** is allowed. This overwrites the original files.


----------

