CMD.exe Batch File/ Script

October 21, 2009 at 11:20:39
Specs: Windows XP
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!


See More: CMD.exe Batch File/ Script

Report •

October 21, 2009 at 12:21:06
@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 felicity


Report •

October 23, 2009 at 00:09:25
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!


Report •

Related Solutions

Ask Question