메모

도스 dir /s 파일 폴더 찾기...펌

맘편한넘 2013. 7. 13. 21:36

How to search a hard drive for a directory name using DOS

Is there a way to find a file on the C: of a computer , using a DOS command, without having to CD to the root of the C: drive? I would like to do it using the DIR and the FINDSTR command only.

Ultimately, my goal is to search for a file and then store the parent directory name in a ENV variable without changing directories and hopefully without creating a temp file.

share|improve this question
Is writing a small console app out of the question? Also, what should it do if your search finds multiple files with the same name?JohnFx Mar 1 '10 at 22:08

This gets the complete file name with directory in a useable form.

dir C:\FILENAME.EXT /s /b
share|improve this answer
yes indeed. thats it. i didn't realize the /b option did that. thanks, thats what I needed.djangofan Mar 1 '10 at 23:03
actual command I used was: dir c:\dirname /s /b /ADdjangofan Mar 1 '10 at 23:11
@djangofan, /b just lists the results in bare format. See dir /?. It is not required. The answer should indicate this.Matthew Doucette Feb 16 '12 at 16:40