How to Remove Blank Lines from text file in msdos?

I have a program that generates a CSV file with extra blank lines at the end.  It is never the same number of lines and the file name changes each time the program is run but always starts out with "APPTS" and ends with the "TXT" extension.
I am looking for a batch file that will remove all the blank lines but keep the file name the same.
It also needs to work with wildcards.
Running it from the command line should look something like this:

Clean.bat appts*.txt

j-heartAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

knightEknightCommented:
findstr  .  myfile.txt > myNewFile.txt
0
j-heartAuthor Commented:
This works only if I know the file name in advance.
If I use a wildcard it appends the file name to the beginning of each line.

So if I run:

findstr  .  myfile.txt > myNewFile.txt

The output to file myNewFile.txt is perfect.

But if I run

findstr  .  myfile*.txt > myNewFile.txt

Then each line starts with the filename:

"myfile.txt:"

Since the program that generates the CSV file generates a rather random series of underscores and numbers after the "appts" begining, I need to be able to use wildcards.
0
oBdACommented:
Try this:
@echo off
setlocal
set FileMask=%~1
for %%a in ("%FileMask%") do (
  ren "%%a" "%%~na.old"
  findstr . "%%~dpna.old" "%%a"
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
oBdACommented:
Sorry, the redirection got lost in line 6:
@echo off
setlocal
set FileMask=%~1
for %%a in ("%FileMask%") do (
  ren "%%a" "%%~na.old"
  findstr . "%%~dpna.old" >"%%a"
)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.