Computing.Net > Forums > Windows XP > CMD.exe Batch File/ Script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

CMD.exe Batch File/ Script

Reply to Message Icon

Name: Dalgetty
Date: October 21, 2009 at 11:20:39 Pacific
OS: Windows XP
Subcategory: General
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: October 21, 2009 at 12:21:06 Pacific
Reply:

@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

M2


1

Response Number 2
Name: Dalgetty
Date: October 23, 2009 at 00:09:25 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


wont do anything Where can I find Whistler...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: CMD.exe Batch File/ Script

Batch file > auto close cmd window www.computing.net/answers/windows-xp/batch-file-auto-close-cmd-window/98455.html

How to add a exe to startup using batch file www.computing.net/answers/windows-xp/how-to-add-a-exe-to-startup-using-batch-file/180673.html

Win XP batch to read text file www.computing.net/answers/windows-xp/win-xp-batch-to-read-text-file/166182.html