How do a wildcard listing ?

T

Tim

Hi,

I have a W2K machine where there are logfiles
C:\Log\01\ComLog08.txt
(where 01 is the day of month, & 08 is the hour)
generated.

Thus, name of the logfile is changed every hour and file
is also stored in different directory ie, 02,03, etc every
day.

I need to know a command string at the DOS prompt
resulting in the output below
C:\Log\01\ComLog00.txt
..
C:\Log\01\ComLog08.txt
C:\Log\01\ComLog09.txt
..
..
C:\Log\02\ComLog00.txt
C:\Log\03\ComLog00.txt
..
..

I have tried using wildcards in the middle of the command,
example
c:>dir c:\Log\*\ComLog??.txt
but gives
"The filename, directory name, or volume label syntax is
incorrect". Furthermore if it works, the date and time..
unnecessary information is displayed.

Sorry, I am not much of a Windows batch file person so any
help is greatly appreciated. Any ideas ?
 
P

Phil Robyn [MVP]

Tim said:
Hi,

I have a W2K machine where there are logfiles
C:\Log\01\ComLog08.txt
(where 01 is the day of month, & 08 is the hour)
generated.

Thus, name of the logfile is changed every hour and file
is also stored in different directory ie, 02,03, etc every
day.

I need to know a command string at the DOS prompt
resulting in the output below
C:\Log\01\ComLog00.txt
.
C:\Log\01\ComLog08.txt
C:\Log\01\ComLog09.txt
.
.
C:\Log\02\ComLog00.txt
C:\Log\03\ComLog00.txt
.
.

I have tried using wildcards in the middle of the command,
example
c:>dir c:\Log\*\ComLog??.txt
but gives
"The filename, directory name, or volume label syntax is
incorrect". Furthermore if it works, the date and time..
unnecessary information is displayed.

Sorry, I am not much of a Windows batch file person so any
help is greatly appreciated. Any ideas ?

Maybe something like

01. @echo off
02. setlocal
03. for /l %%a in (101,1,131) do call :main %%a
04. goto :EOF
05. :main
06. set day=%1
07. set day=%day:~1%
08. if not exist C:\Log\%day%\. goto :EOF
09. dir /s /b C:\Log\%day%\ComLog*.txt
10. goto :EOF
 
M

Michael Bednarek

Hi,

I have a W2K machine where there are logfiles
C:\Log\01\ComLog08.txt
(where 01 is the day of month, & 08 is the hour)
generated.

Thus, name of the logfile is changed every hour and file
is also stored in different directory ie, 02,03, etc every
day.

I need to know a command string at the DOS prompt
resulting in the output below
C:\Log\01\ComLog00.txt
.
C:\Log\01\ComLog08.txt
C:\Log\01\ComLog09.txt
.
.
C:\Log\02\ComLog00.txt
C:\Log\03\ComLog00.txt
.
.

I have tried using wildcards in the middle of the command,
example
c:>dir c:\Log\*\ComLog??.txt
but gives
"The filename, directory name, or volume label syntax is
incorrect". Furthermore if it works, the date and time..
unnecessary information is displayed.

Sorry, I am not much of a Windows batch file person so any
help is greatly appreciated. Any ideas ?

Would the output of
DIR /S /B C:\log\*.txt
be satisfactory?
 
T

Tim

-----Original Message-----
Maybe something like

01. @echo off
02. setlocal
03. for /l %%a in (101,1,131) do call :main %%a
04. goto :EOF
05. :main
06. set day=%1
07. set day=%day:~1%
08. if not exist C:\Log\%day%\. goto :EOF
09. dir /s /b C:\Log\%day%\ComLog*.txt
10. goto :EOF

--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a
i l
Thanks Phil,
You are a genius ! It's gizmo to me but it sure works :)
 
T

Tim

-----Original Message-----


Would the output of
DIR /S /B C:\log\*.txt
be satisfactory?

Yeah..:) Very elegant solution... Looks like I learn quite
a few things here. Thanks a lot.
 
G

Guest

How about dir "c:\log\??\comlog??.txt /s" from c:\ - this should give you ONLY your log files
 
M

Michael Bednarek

How about dir "c:\log\??\comlog??.txt /s" from c:\ - this should give you ONLY your log files
[snip]

No, it doesn't. Under NT5.0, CMD responds to that command:
The filename, directory name, or volume label syntax is incorrect.

What response do you get?
 
D

David Candy

It unnecessary. The /s handles sub directories.

dir c:\log\*.* /s
--
----------------------------------------------------------
'Not happy John! Defending our democracy',
http://www.smh.com.au/articles/2004/06/29/1088392635123.html

ZFetsh said:
Dammit, I thought it would work. XP comes up with
The filename, directory name, or volume label syntax is incorrect

Grr, I thought it would work, but I guess I should have tested it first ...


Michael Bednarek said:
How about dir "c:\log\??\comlog??.txt /s" from c:\ - this should give you ONLY your log files
[snip]

No, it doesn't. Under NT5.0, CMD responds to that command:
The filename, directory name, or volume label syntax is incorrect.

What response do you get?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top