Need help on DIR command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DOSThings
Posts: 1
Joined: 17 Feb 2009 12:40
Location: Bangalore

Need help on DIR command

#1 Post by DOSThings » 17 Feb 2009 13:13

Hi All,

I am quite new to DOS programming. I am currently stuck with a problem which I am sure many of you already know.
My requirement is to get the list of all folders and sub-folders in relative path format.

For example, the command "DIR C:\DRIVERS /s /B /A:D" lists down all the folders and sub-folders present under C:\DRIVERS. However, all these are fully qualified:

C:\DRIVERS\AUDIO
C:\DRIVERS\FPR
C:\DRIVERS\LPM
C:\DRIVERS\WLLANBCM
C:\DRIVERS\AUDIO\SMAXWDM
C:\DRIVERS\AUDIO\Sys
C:\DRIVERS\AUDIO\SMAXWDM\W2K_XP

What I want is as follows -

\AUDIO
\FPR
\LPM
\WLLANBCM
\AUDIO\SMAXWDM
\AUDIO\Sys
\AUDIO\SMAXWDM\W2K_XP

Can I achieve this by using a different form of DIR command or manipulating the 1st list in some way? I need the solution real quick. Any help will be greatly appreciated.


Thanks.

jaffamuffin
Posts: 40
Joined: 25 Jan 2008 14:05

#2 Post by jaffamuffin » 17 Feb 2009 15:40

Use the expansion shortcuts.

if %1 is c:\drivers\audio

then %~pn1 is \drivers\audio
and %~n1 is \audio\

etc

Post Reply