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.
Remove blank first line
Name: Fut Date: June 8, 2009 at 14:56:28 Pacific OS: Windows Vista Subcategory: Batch
Comment:
Hi. I need to remove the first (or 2) blank lines in around 2000 txt-files.
I've found and tried this: @echo off setLocal EnableDelayedExpansion if exist *.new del *.new for /f "tokens=*" %%A in ('dir /b *.txt') do ( set NAME=%%~nA set fileNAME=%%A for /f "tokens=*" %%L in (!fileNAME!) do ( echo %%L >> !NAME!.new ) )
But it removes ALL empty lines in the txt-files. It's songs, and there is 1-2 empty lines first, then a verse, an empty line, verse 2 and so on - and I need the empty lines between verses, but none at the file-top. Is it possible to delete only the first line ? (And maybe check if it's blank before - gives the possibility to run the files again to remove the blank lines in the files with 2 empty lines). Thanks, Soren from Denmark.
Thanks ! Works fine (on 1 file at a time). Can't figure out how to make it take all *.txt files in a directory, process (delete first line) and save in original (or new) file-name. Any ideas are much appreciated !
Can't figure out what the "if "%%b" neq "" -line is doing ?
Summary: Hi dtech10, No errors. Here's the before & after on a smaller file: ### before EUR Euro GBP United Kingdom Pounds CAD Canada Dollars AUD Australia Dollars JPY Japan Yen INR India Rupees NZD New Zeala...
Summary: I found this code on this forum : It deletes the first 4 lines of a text file, but I only want it to delete the first line... I do not understand this syntax and where to change it.. Can somone help? ...
Summary: Does anyone know how to delete the first line of text from a text file using a batch file (or a simple way from the command line)? Thanks, Cory ...