I'm having trouble getting files names to be outputted into a text file. As of now I can only get the directory names to be outputted and not the files within. Right now I have:
FOR /D %%I IN ("\\server\data\jan-2010\*") DO dir /b "%%I" >> "%userprofile%\desktop\output.txt"
The above code just copies the directory names within the "jan-2010" folder. I need it to copy the file names within those directories into the text file. I'm stumped.
Any help would be appreciated.
Thanks!
Dir command Output into a Text file
Moderator: DosItHelp
Re: Dir command Output into a Text file
You could try something like this:
You could even play with the /s switch in the dir command to parse through layers of subfolders. Is this any help?
Code: Select all
SET directory=\\server\data\jan-2010
FOR /F "tokens=*" %%I in ('dir %directory% /ad /b') DO dir "%directory%\%%I" /a-d /b >> dir.txt
You could even play with the /s switch in the dir command to parse through layers of subfolders. Is this any help?
Re: Dir command Output into a Text file
I think that did the trick.
Thanks so much!
Thanks so much!