Need DOS Batch (DIR command) help

Posted by: SonicSnoop

Need DOS Batch (DIR command) help - 09/11/2006 04:51

Hey guys hows it going.. A friend had asked me some help with a dos batch file. he wanted one where he could enter the dir to scan for mp3's and put it into a text file. Here is the code:

Code:

@echo off

set /P dir=Directory: %=%
set /p file=Output File Name: %=%

dir /s /w /b %dir%\*.mp3 > %file%



Is there a way to get this to not show the dir's in front of the file names? Thanks guys!
Posted by: furtive

Re: Need DOS Batch (DIR command) help - 09/11/2006 07:29

Replacing the /b flag with /n will remove the directory names from the file names, but will show the files in several columns rather than a single column. Don't know if this is any help
Posted by: JBjorgen

Re: Need DOS Batch (DIR command) help - 09/11/2006 11:05

Try this:

Code:

@echo off

set /P dir=Directory: %=%
set /p file=Output File Name: %=%
FOR /R %dir% %%i IN (*.mp3) DO @echo %%~nxi >> %file%



It's slower, but should work.

EDIT: Also note that if the same output filename is used again, it will append to that file instead of overwriting it. That's pretty easily fixable though.
Posted by: SonicSnoop

Re: Need DOS Batch (DIR command) help - 10/11/2006 23:24

Thank you for the replies! HE was able to get it where he wanted with these posts!