tags:

views:

250

answers:

4

Hi,

I want to search *.cpp files in current directory and want to save the file name in *.TXT file. I did this by using the Batch command

dir |find ".cpp" > Listfile.txt

But there I am getting file name with entire paramenters like created date and size.

My need is I want only file name

Current output
06/25/2010  06:17 PM               950 4mLinuxMachine.cpp
06/28/2010  03:41 PM             4,236 Linux11.cpp

Need Output
4mLinuxMachine.cpp
Linux11.cpp

Please help Thanks

A: 

Use bare format: dir /B

dir /B |find ".cpp" > Listfile.txt

Othe options you can find using:

dir /?
Pmod
A: 

If you don't mind installing or using cygwin tools, this task can be done like so:

find . -type f -name '*.cpp' -print > Listfile.txt
sarnold
Cygwin for that? Too much overkill.
Camilo Martin
If this is the only problem being solved, yes. But cygwin comes with a huge collection of immensely useful little tools which can be strung together to solve an endless variety of problems.The way I figure it, cygwin should have been on the machine in the first place. :)
sarnold
+3  A: 

Try:

dir /b | find ".cpp" > Listfile.txt

or better still:

dir /b *.cpp > Listfile.txt
Paul R
Hey I didn't know you could use wildcards in dir! +1 :)
Camilo Martin
Can i store the cpp file names in Listfile to some variable for later use
Hey! I answered earlier ;)
Pmod
Thanks for your reply...Here my intention is to take all*.cpp files in ListFile.txt line by line
@sureshdharmadurai: I think you're going to run into the limitations of DOS batch files pretty quickly - I suggest you take the advice of samold below - install cygwin and learn bash - it will make tasks like this a lot easier (and more portable too).
Paul R
@Pmod: bad luck ! ;-)
Paul R
Currently i cant install cygwin and its not possible for my project.There is no facility install or copy any files.I want to take data from text file line by line thats enough. Any commend is there for this
@sureshdharmadurai Look at the `FOR` command for looping through ListFile.txt. Type `FOR /?` in a cmd prompt for more info.
aphoria
A: 

Search from the file explorer and use this shell extension to copy from the context menu: http://grebulon.com/software/copylocation.php

"This shell extension adds the ability to copy file and folder names from the Windows Explorer window to the clipboard. Simply select the file(s) whose name you want to copy, right-click and select "Copy File Path" or "Copy File Name" from the context menu. Then paste to any editor. Copy File Path - copies the entire path to the file. Copy File Name - copies only the file name without the folder."

grebulon