I have a bat file that searches a directory for specific .csv files names, and copies and amends the lines into a new .csv file.

However, some of the lines of the original .csv files are not information needed, and begin with PO-. I'd like to add to my bat a way to search for cells containing "PO-" and delete the entire line, and then save the results in a new .csv file. Is it possible?.

What I have so far in my .bat file is:


@ Echo off

Echo on

type NUL>fdx.csv

copy pds*.csv fdx.csv
  • 3
    It would help if you were to post your batch file code. – Josh Apr 16 '14 at 17:49
  • Do you want a .bat file or a macro for excel? You have both tagged. – Raystafarian Apr 16 '14 at 18:10
  • Sorry new to all of this. I'd like a .bat file. What I have in my .bat already is: type NUL>fdx.csv copy pds*.csv fdx.csv Echo on – Hoehner Apr 16 '14 at 18:17
  • Please edit your question to provide the requested information. – EBGreen Apr 16 '14 at 18:31

Perhaps you could use FIND

find /V "PO-" fdx.csv > new.csv

but you will get a header on the csv file that you have to remove manually


FINDSTR will work better;

findstr /v /i /b "PO-" fdx.csv > new.csv

/v will exclude lines with "PO-"

/b will only look for PO- at the beginning of the line

/i will make it case-insensitive (so Po-, po- pO-)

Or, with FIND, you could use MORE +x to skip x lines and remove the header it leaves behind;

more +1 | find /v "PO-" fdx.csv > new.csv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.