how to get the name of the text file in dos

July 13, 2010 at 13:28:25
Specs: Windows XP
i need to get the name of files in a particular directory and store that name in one text file using dos commands.

EX :the unix command is
system("ls *.* | awk -F . '{print $1}' > great.list");
please help me to solve this issue.


See More: how to get the name of the text file in dos

Report •


#1
July 13, 2010 at 13:47:24
Try this:

FOR /f "tokens=*" %%i in ('dir /b *.*') do (
ECHO %%i >> greatlist.txt )

MIKE

http://www.skeptic.com/


Report •

#2
July 13, 2010 at 14:59:24
Better:
dir /b > great.list


Report •

#3
July 13, 2010 at 16:45:35
you can also use ls in windows. download coreutils for windows

then just do ls with -1 option

c:\> ls -1 > file

GNU win32 packages | Gawk


Report •

Related Solutions

#4
July 14, 2010 at 04:44:52
thanks a lot.

Better:
dir /b > great.list

the above one is working. but i don't want Extension of file.

kindly do the needful


Report •

#5
July 14, 2010 at 05:17:16
Working off of Response #1:
FOR /f "tokens=*" %%I in ('dir /b /a-d *.*') do (
    ECHO.%%~nI>> greatlist.txt 
)

When your only tool is a hammer, every problem looks like a nail.


Report •

#6
July 14, 2010 at 05:43:44
vasubalamurugan: i don't want Extension of file.
Technically, it has the extension of list. But if you insist:
dir /b > great.list.txt


Report •


Ask Question