Log Parser Directory Listing

J

Justin Fancy

Does anyone know how to use Log Parser to output a list of filenames in
a folder and all its subfolders, to a text file? I hear this way is 100
times quicker than doing a "dir".

If you know any other methods for conveniently loading in a 100MB file,
could you please let me know.

Justin
 
A

Alexander Suhovey

Justin Fancy said:
Does anyone know how to use Log Parser to output a list of filenames in
a folder and all its subfolders, to a text file? I hear this way is 100
times quicker than doing a "dir".

If you know any other methods for conveniently loading in a 100MB file,
could you please let me know.

Justin,

LogParser comes with excelent documentation in CHM format. Find
LogParser.chm file in LogParser folder. How to use file system as an input
for LogParser is described in "LogParser \ Reference \ Input Formats \ FS"

Here's an example (one line command) that will "dir" your windows directory:

c:\>LogParser "SELECT Path, Name, Size FROM
%systemroot%\*.*" -recurse:0 -i:FS -o:NAT -rtp:-1

Note that output format and amount of data you get is highly customisable so
if you don't like the one of previous command, you can change it to include
whatever you need. It's SQL query format you are dealing with here. It's
amazingly powerful.

Talking about speed, I found LogParser *extremely* quicker when working with
different kinds of input data such as text files, Windows evend logs and
registry than other programs and casual cmd commands like TYPE, ECHO and
FOR. Well, maybe not 100 *times* quicker but 100-200 *percents* or more -
easily.

Never used it as a replacement to dir though but I wouldn't be surprised if
it will be as quick with FS as with other input types.
 
J

Justin Fancy

I need to display ONLY files. Is that possible? I looked over the CHM
file, thanks for that, but couldn't find anything on outputting only
files.

Justin
 
M

Mark [exmsft]

Hello Justin,
I need to display ONLY files. Is that possible? I looked over the CHM
file, thanks for that, but couldn't find anything on outputting only
files.

Justin


Add a "Where attributes not like 'D%'" to your query:

LogParser "SELECT Path, Name, Size FROM %systemroot%\*.* where attributes
not like 'D%'" -recurse:0 -i:FS -o:NAT -rtp:-1

thanks,
Mar
 
J

Justin Fancy

One more question, i know I can pull out the LastAccessTime attribute
but I need to only ouput the files that were last accessed in 1995.

I tried this and it returned nothing, and I checked the files and yes,
there are files tahtw ere last accessed in 1995:

LogParser "SELECT Path, Name, Size FROM c:\*.* where 'LastAccessTime'
LIKE '1995'" -recurse:0 -i:FS -o:NAT -rtp:-1


0 files get ouput. Any suggestions?
 
A

Alexander Suhovey

Justin Fancy said:
One more question, i know I can pull out the LastAccessTime attribute
but I need to only ouput the files that were last accessed in 1995.

I tried this and it returned nothing, and I checked the files and yes,
there are files tahtw ere last accessed in 1995:

LogParser "SELECT Path, Name, Size FROM c:\*.* where 'LastAccessTime'
LIKE '1995'" -recurse:0 -i:FS -o:NAT -rtp:-1


0 files get ouput. Any suggestions?

1. Your query will never produce any output since your condition will never
be true. You are comparing two static literal strings - 'LastAccessTime' and
'1995'.

2. Since LastAccessTime is of type timestamp, not string, you need to
compare it with another timestamp. Something like this should do the trick
(one-liner):

LogParser "SELECT Path,Name,Size,LastAccessTime FROM c:\*.* where
LastAccessTime<=TO_LOCALTIME(TIMESTAMP('1995-01-01', 'yyyy-MM-dd')) ORDER by
LastAccessTime" -recurse:0 -i:FS -o:NAT -rtp:-1

You can find other similar examples in logparser.chm

3. Be aware that by default logparser (as well as most of programs) changes
last access timestamp of file system objects it accesses. There's a swith to
control this behaviour:

-preserveLastAccTime ON|OFF (default is OFF)
 
J

Justin Fancy

But will I get all the files that were accessed last in 1995? Or just
those that were access on January 1st, 1995?

J
 
A

Alexander Suhovey

-----Original Message-----
From: Justin Fancy [mailto:[email protected]]
Posted At: Friday, November 10, 2006 2:59 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: Log Parser Directory Listing
Subject: Re: Log Parser Directory Listing

But will I get all the files that were accessed last in 1995? Or just
those that were access on January 1st, 1995?

Last time I checked "<=" was "less than or equal" so yes, you should see
all files/folders whose last accss timestamp is less or equal than
January 1st, 1995, 00:00 local time. If you need to see those accessed
at specified time, use "=" instead.

If you look at the query:

"SELECT Path,Name,Size,LastAccessTime FROM c:\*.* WHERE
LastAccessTime<=TO_LOCALTIME(TIMESTAMP('1995-01-01', 'yyyy-MM-dd'))
ORDER by LastAccessTime"

you could see that it is easily readable in common words like this:

"Show me path, name, size and last access time of each file/folder in
c:\ with a dot in their name, whose last access time is less than or
equal January 1st, 1995 (local time) and sort the output by last access
time"
 
J

Justin Fancy

It doesnt seem to be working?

Here's what i tried to query:

"SELECT Path,Name,Size,LastWriteTime FROM c:\*.* WHERE
LastWriteTime<=TO_LOCALTIME(TIMESTAMP('1995-12-31', 'yyyy-MM-dd'))
ORDER BY LastWriteTime"

It shows as error:

'ORDER' is not recognized as an internal or external command, operable
program or batch file.

When I take the ORDER clause out I get:

The system cannot find the file specified.

J
 
A

Alexander Suhovey

-----Original Message-----
From: Justin Fancy [mailto:[email protected]]
Posted At: Friday, November 10, 2006 4:35 PM
Posted To: microsoft.public.win2000.cmdprompt.admin
Conversation: Log Parser Directory Listing
Subject: Re: Log Parser Directory Listing


It doesnt seem to be working?

Here's what i tried to query:

"SELECT Path,Name,Size,LastWriteTime FROM c:\*.* WHERE
LastWriteTime<=TO_LOCALTIME(TIMESTAMP('1995-12-31', 'yyyy-MM-dd'))
ORDER BY LastWriteTime"

It shows as error:

'ORDER' is not recognized as an internal or external command, operable
program or batch file.

When I take the ORDER clause out I get:

The system cannot find the file specified.

J

Justin, the query you are quoted must be one line. Following works fine
for me (SINGLE LINE command):

logparser.exe "SELECT Path,Name,Size,LastWriteTime FROM c:\*.* WHERE
Attributes not like 'D%' AND
LastWriteTime<=TO_LOCALTIME(TIMESTAMP('2006-12-31', 'yyyy-MM-dd')) ORDER
BY LastWriteTime" -recurse:0 -i:FS -o:NAT -rtp:-1

Note also that when using it in batch files, you need to double '%' sign
so it is recognized literally. Specifically, 'D%' should be 'D%%' when
command above used in batch.
 
D

daniel.magrini

Justin, the query you are quoted must be one line. Following works fine
for me (SINGLE LINE command):

logparser.exe "SELECT Path,Name,Size,LastWriteTime FROM c:\*.* WHERE
Attributes not like 'D%' AND
LastWriteTime<=TO_LOCALTIME(TIMESTAMP('2006-12-31', 'yyyy-MM-dd')) ORDER
BY LastWriteTime" -recurse:0 -i:FS -o:NAT -rtp:-1

Note also that when using it in batch files, you need to double '%' sign
so it is recognized literally. Specifically, 'D%' should be 'D%%' when
command above used in batch.

Sorry, i need insert yesterday date : "C:\Programmi\Log Parser
2.2\LogParser.exe" "SELECT COUNT(cs-uri-stem) FROM E:\log1\ex*.log
WHERE cs-uri-stem like '/Download/it/ConfigAliceMessenger.exe%' AND
date=*****YESTERDAY DATE IN THIS FORMAT YYYY-MM-DD******** " -q
YESTERDAY DATE IN THIS FORMAT YYYY-MM-DD.txt

What can i do it?

Thans a lot
Daniel
 
F

foxidrive

Sorry, i need insert yesterday date : "C:\Programmi\Log Parser
2.2\LogParser.exe" "SELECT COUNT(cs-uri-stem) FROM E:\log1\ex*.log
WHERE cs-uri-stem like '/Download/it/ConfigAliceMessenger.exe%' AND
date=*****YESTERDAY DATE IN THIS FORMAT YYYY-MM-DD******** " -q

@echo off
:: from code by Phil Robyn
setlocal
if [%1]==[] (
echo to get todays date use
echo call "%~n0" today 0
echo.
echo to get yesterdays date use
echo call "%~n0" today -1
echo.
echo to get the date 25 days ago:
echo call "%~n0" today -25
echo.
echo to get the date 1250 days in the future
echo call "%~n0" today +1250
goto :EOF)

set date1=%1
set qty=%2
if /i "%date1%" EQU "TODAY" (
set date1=now
) else (
set date1="%date1%"
)
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs" right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs" right(100+day(s),2)
for /f %%a in (
'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set day=%result:~0,4%-%result:~4,2%-%result:~6,2%
echo %%day%% is set to "%day%" (without the quotes)
 
D

daniel.magrini

foxidrive ha scritto:
Sorry, i need insert yesterday date : "C:\Programmi\Log Parser
2.2\LogParser.exe" "SELECT COUNT(cs-uri-stem) FROM E:\log1\ex*.log
WHERE cs-uri-stem like '/Download/it/ConfigAliceMessenger.exe%' AND
date=*****YESTERDAY DATE IN THIS FORMAT YYYY-MM-DD******** " -q

@echo off
:: from code by Phil Robyn
setlocal
if [%1]==[] (
echo to get todays date use
echo call "%~n0" today 0
echo.
echo to get yesterdays date use
echo call "%~n0" today -1
echo.
echo to get the date 25 days ago:
echo call "%~n0" today -25
echo.
echo to get the date 1250 days in the future
echo call "%~n0" today +1250
goto :EOF)

set date1=%1
set qty=%2
if /i "%date1%" EQU "TODAY" (
set date1=now
) else (
set date1="%date1%"
)
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs" right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs" right(100+day(s),2)
for /f %%a in (
'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set day=%result:~0,4%-%result:~4,2%-%result:~6,2%
echo %%day%% is set to "%day%" (without the quotes)

Sorry, i need of put it on .bat....! But not works :(

Thanks
Daniel
 
D

daniel.magrini

foxidrive ha scritto:
Sorry, i need insert yesterday date : "C:\Programmi\Log Parser
2.2\LogParser.exe" "SELECT COUNT(cs-uri-stem) FROM E:\log1\ex*.log
WHERE cs-uri-stem like '/Download/it/ConfigAliceMessenger.exe%' AND
date=*****YESTERDAY DATE IN THIS FORMAT YYYY-MM-DD******** " -q

@echo off
:: from code by Phil Robyn
setlocal
if [%1]==[] (
echo to get todays date use
echo call "%~n0" today 0
echo.
echo to get yesterdays date use
echo call "%~n0" today -1
echo.
echo to get the date 25 days ago:
echo call "%~n0" today -25
echo.
echo to get the date 1250 days in the future
echo call "%~n0" today +1250
goto :EOF)

set date1=%1
set qty=%2
if /i "%date1%" EQU "TODAY" (
set date1=now
) else (
set date1="%date1%"
)
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs" right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs" right(100+day(s),2)
for /f %%a in (
'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set day=%result:~0,4%-%result:~4,2%-%result:~6,2%
echo %%day%% is set to "%day%" (without the quotes)



Active: Today @ 12:09 PM
Posts: 2

ok, i resolve in this mode on .bat:

@ECHO OFF
ECHO %DATE%
echo >%temp%.\tmp.vbs y = DateAdd("d",-1,now)
echo>>%temp%.\tmp.vbs m = CStr(Month(y))
echo>>%temp%.\tmp.vbs m = CStr(Right("0"+m,2))
echo>>%temp%.\tmp.vbs d = CStr(Day(y))
echo>>%temp%.\tmp.vbs d = CStr(Right("0"+d,2))
echo>>%temp%.\tmp.vbs y = CStr(Year(y))
echo>>%temp%.\tmp.vbs WScript.Echo "set yesterday="+y+m+d
cscript //nologo %temp%.\tmp.vbs > %temp%.\tmp.bat
call %temp%.\tmp.bat
del %temp%.\tmp.bat
echo %yesterday%
set DATA=%yesterday:~0,4%-%yesterday:~-4,2%-%yesterday:~6,2%
set QUERY="SELECT COUNT(cs-uri-stem) INTO %DATA%.csv FROM
E:\log1\ex*.log WHERE cs-uri-stem like
'/Download/it/ConfigAliceMessenger.exe%' AND date='%DATA%'"
ECHO %DATA%
"C:\Programmi\Log Parser 2.2\LogParser.exe" %QUERY%
ECHO %DATA%
PAUSE

BUT on date='%DATA%' not assigned valid value????
IT not respond error, but query result not correct! why? If insert
manual value in date='2006-12-21' result OK! with ECHO %DATA% show on
screen correct!

Thanks
Daniel
 

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