dir without path?

  • Thread starter Thread starter George Hester
  • Start date Start date
G

George Hester

I need to use the dir command to get a listing of files off the CD-ROM. But
I do not what the path in the names of the files. I tried:

dit /s /b > d:\DVDs\DVD1.txt

But this gives the path. Is there some switch that I can use to avoid the
drive letter in the list? thanks.
 
-----Original Message-----
From: George Hester [mailto:[email protected]]
Posted At: Monday, November 27, 2006 5:30 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: dir without path?
Subject: dir without path?

I need to use the dir command to get a listing of files off the CD-ROM. But
I do not what the path in the names of the files.

George,

Try this:

for /r "e:\" %i in (*.*) do @echo %~nxi

where e:\ is your CD/DVD drive letter. When used in batch scripts,
double percent signs (%%i instead of %i).
 
Alexander said:
for /r "e:\" %i in (*.*) do @echo %~nxi


Hi Alexander,

that doesn't return the path.


This should do: (doesn't include dir names, ordered by name,ext)

for /f "tokens=*" %A in ('dir /B/A-D/S/ONE G:\*') do @echo/%~pnxA


HTH
Matthias
 
Excellent Alexander. Worked pretty good. I put what you had in a bat file
called name.bat and did this in the folder where I want to place these
listings:

name > BIBLE1.txt.

What I got was the listing just as I asked for and the command itself in the
bat. I should lead the bat off with
@echo off
?

--

George Hester
_________________________________
Alexander Suhovey said:
-----Original Message-----
From: George Hester [mailto:[email protected]]
Posted At: Monday, November 27, 2006 5:30 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: dir without path?
Subject: dir without path?

I need to use the dir command to get a listing of files off the CD-ROM. But
I do not what the path in the names of the files.

George,

Try this:

for /r "e:\" %i in (*.*) do @echo %~nxi

where e:\ is your CD/DVD drive letter. When used in batch scripts,
double percent signs (%%i instead of %i).
 
OK here we go. Without a bat file:

D:\DVDs\(for /R "h::\" %i in (*.*) do @echo %~nxi) > BIBLE1.txt

where h: is the CD-ROM drive. Thanks.

--

George Hester
_________________________________
Alexander Suhovey said:
-----Original Message-----
From: George Hester [mailto:[email protected]]
Posted At: Monday, November 27, 2006 5:30 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: dir without path?
Subject: dir without path?

I need to use the dir command to get a listing of files off the CD-ROM. But
I do not what the path in the names of the files.

George,

Try this:

for /r "e:\" %i in (*.*) do @echo %~nxi

where e:\ is your CD/DVD drive letter. When used in batch scripts,
double percent signs (%%i instead of %i).
 
George Hester said:
OK here we go. Without a bat file:

D:\DVDs\(for /R "h::\" %i in (*.*) do @echo %~nxi) > BIBLE1.txt

where h: is the CD-ROM drive. Thanks.

In a batch file the % used to note for variables (e.g., %a, %i)
must be doubled (e.g., %%a, %%i).

It's a quirk of the command line versus batch file parsing.

--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
--

George Hester
_________________________________
Alexander Suhovey said:
-----Original Message-----
From: George Hester [mailto:[email protected]]
Posted At: Monday, November 27, 2006 5:30 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: dir without path?
Subject: dir without path?

I need to use the dir command to get a listing of files off the CD-ROM. But
I do not what the path in the names of the files.

George,

Try this:

for /r "e:\" %i in (*.*) do @echo %~nxi

where e:\ is your CD/DVD drive letter. When used in batch scripts,
double percent signs (%%i instead of %i).
 
Back
Top