I have the following command:

find Acc*\bin\Debug\*.pdb > temp.txt

Looking in temp.txt, I have:

Accounting/bin/Debug/Accounting.pdb
Accounting/bin/Debug/BackendProcess.pdb

NOTE the forward slashes. Why does it output file names like this? And how do I get it to output backslashes, so I can use del on those files?

Thanks

link|improve this question
feedback

migrated from stackoverflow.com Jun 7 '10 at 9:35

This question came from our site for professional and enthusiast programmers.

4 Answers

find looks for a search string in files. Perhaps you are looking for something like dir *.pdb /S /B > temp.txt instead?

link|improve this answer
feedback

I'm looking to list the files with the wildcards I mentioned. Dir cannot do that. Find works fine if the output is in the console:

find Acc*\bin\Debug\*.pdb

will output

Accounting\bin\Debug\Accounting.pdb
Accounting\bin\Debug\BackendProcess.pd

It's just the file redirection that goes wrong.

link|improve this answer
When clarifying your question, please use the "edit" link on the question. Don't post an answer to clarify the question. – T.J. Crowder Jun 7 '10 at 10:19
feedback

It looks like you use a poor port of the UNIX find(1) command and not the (formerly-DOS) find utility. Since you apparently have those tools on your machine anyway you can just use rm(1) instead of del on those files.

Another option is to iterate over the output and replace the virgule by a backslash (assuming a batch file here):

setlocal enableextensions enabledelayedexpansion
for /f "delims=" %%x in ('find Acc*\bin\Debug\*.pdb') do (
    set fn=%%x
    set fn=!fn:/=\!
    >>temp.txt echo.!fn!
)
link|improve this answer
Short note on why rm works: The Windows API usually has no problems with forward slashes instead of backslashes. However, the built-in commands in cmd do have problems. Since del is a shell built-in and rm is not, it works with rm even with forward slashes. – Joey Jun 7 '10 at 12:54
You were right, I had some unix tools installed, and rm worked. Thank you very much. – mihai Jan 7 '11 at 17:28
feedback

I think you used some sort of port for find(1) on DOS. if you have find, i think you may also have sed as well.. and then...

find condition | sed 's/\//\/g'

this should do the job.

otherwise, follow what @Johannes Rössel said.

link|improve this answer
1  
Ah, right. Should have thought of sed(1). In any case, a port that imposes UNIX filename semantics on foreign OSes is not really worth using, imho. – Joey Jun 7 '10 at 12:52
feedback

Your Answer

 
or
required, but never shown