9

What I want to do seems very simple:
I have a folder in Windows containing items of various types including PDF files, TXT files, and subdirectories. I am writing a one line .bat file to pull ONLY the PDF file names into a new text file.

So far this is what I have in the .bat:

dir *.pdf /b > PDF_LIST.txt

This gives the following output in a PDF_LIST.txt file:

A.pdf
B.pdf
C.pdf

I would like to drop the ".pdf" portion of each line in the txt file, since I obviously know already that each file is in PDF format by the *.pdf parameter in my dir statement.

This would just make it easier for me to copy/paste all the file names directly from the text file into a word document for a transmittal I'm sending to my customer. If you can suggest a better or easier way to get the file list without using a batch file that would also would be helpful.

NoCatharsis
  • 3,147

2 Answers2

18

In your script:

for %%i in (*.pdf) do @echo %%~ni >> PDF_LIST.txt
0

Most text editors (including notepad) have find and replace. Just use it to find all ".pdf" and replace it with "". Done :)

You can set this as macro in word, as well.

Sunny
  • 951
  • Yes, I use Notepad++ to do this right now - however I was just wondering if there was a way to cut out one more step by writing it into a script. – NoCatharsis Dec 17 '10 at 17:12