Monday, 13 November 2017

windows - How do I hide file extensions in a command prompt /dir output?


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.



Answer



In your script:


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

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...