473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Searching file system and returning xml based on date search crite

Hello group.
I've migrated from Win 2003 server to Win 2008 server.
I've been banging my head agaist a wall for several days now trying to
figure this out.

I have the following script that will search the file system and return file
names of all files within a folder and subfolders that meet the search
criteria of DateLastModified.

To test the output, you can use the following link:
http://www.hurricanealley.net/GT/ne...008%204:00%20PM
or even change the date time input in the URL.
The input part of the url is the date and time.
To see the actual file dates you can look here:
http://www.hurricanealley.net/GT/Data (sub folders also)

The problem I'm having is that some files names/paths that are returned are
older than the search criteria date/time and some files that are newer are
not being returned.
Any suggestions would be greatly appreciated
--
<%@ Language=VBScript %>
<?xml version="1.0" encoding="iso-8859-1"?>
<%

' Init path parameters
start_path = "data"
start_url = ""

' Parse date param
s = ""
for i = 1 to len(Request.QueryString)
if mid(Request.QueryString, i, 3) = "%20" then s = s + " " : i = i + 2
else s = s + mid(Request.QueryString, i, 1)
next
dim sdate
dim stime
n = 0 : sdate = s : stime = ""
for i = 1 to len(s) - 1
if mid(s, i, 1) = " " and n = 0 then n = i
next
if n 0 then sdate = Trim(Left(s, n - 1)) : stime = Trim(Right(s, Len(s) -
n))

Dim RequestDateTime
RequestDateTime = DateValue(sdate)
if stime <"" then RequestDateTime = RequestDateTime + TimeValue(stime)

' Write root node
%><newfiles fromdate="<%= s %>" datestr="<%= sdate %>" timestr="<%= stime
%>" resultdatetime="<%= RequestDateTime %>">
<%

' Create FileSystemObject variable
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

' Process specified folder
tmp = ProcessFolder(Server.MapPath(start_path), start_url, chr(9), 0)

Set objFSO = Nothing
'---------------------------------------------
' Write file xml-node
Function WriteFile(objItem, strUrl, space)
%><%=space%><file name="<%= objItem.Name %>" size="<%= objItem.Size %>"
date="<%= objItem.DateCreated %>" url="<%= strUrl & objItem.Name %>"/>
<%
End Function

' Process folder
' writemode: 0 - write to xml-page, 1 - return new items count, 2 - return
newitems size
Function ProcessFolder(strPath, strUrl, space, writemode)

Dim objFolder 'Folder variable
Dim objItem 'Variable used to loop through the contents of the folder

' Get a handle on our folder
Set objFolder = objFSO.GetFolder(strPath)

res = 0

'scan files
For Each objItem In objFolder.Files
If (objItem.DateLastModified RequestDateTime) or (objItem.Name =
"ImageMap.xml") Then
If writemode = 0 Then tmp = WriteFile(objItem, strUrl, space)
If writemode = 1 Then res = res + 1
If writemode = 2 Then res = res + objItem.Size
End If
Next 'objItem

'scan subfolders
For Each objItem In objFolder.SubFolders
If InStr(1, objItem, "_vti", 1) = 0 Then
new_path = strPath & "\" & objItem.Name
lchar = "/" : if len(strUrl) 0 then lchar = right(strUrl, 1)
new_url = strUrl & objItem.Name & "/"
If writemode = 0 Then
' calc newitems count and size
items_count = ProcessFolder(new_path, "", "", 1) 'calc count
items_size = ProcessFolder(new_path, "", "", 2) 'calc size
' write folder xml-node
%><%=space%><folder name="<%= objItem.Name %>" newitems="<%=items_count%>"
newitems_size="<%=items_size%>">
<%
tmp = ProcessFolder(new_path, new_url, space + chr(9), writemode)
%><%=space%></folder>
<%
End If
If writemode >= 1 Then
res = res + ProcessFolder(new_path, "", "", writemode)
End If
End If
Next 'objItem

' All done! Kill off our object variables.
Set objItem = Nothing
Set objFolder = Nothing

ProcessFolder = res

End Function

%>
</newfiles>
--------------------------------------------------------------------------------

Thanks!
Bryan
Aug 11 '08 #1
0 1446

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web...
1
by: smita | last post by:
Hi, I want to search an xml file for particular searchstrings and also based on the date i.e. all items containing the date -----prior to the specified date, or ----on that date or ----- after the...
1
by: Saso Zagoranski | last post by:
Hi! This is not exactly a C# question but I don't know where else to post it... I'm making an application where the user keeps track of it's art collection... I'm also trying to implement a...
5
by: justobservant | last post by:
When more than one keyword is typed into a search-query, most of the search-results displayed indicate specified keywords scattered throughout an entire website of content i.e., this is shown as...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
1
by: Timothy | last post by:
Hi All, Please everyone this is my humble request to all of you if you please have idea about my question then please help me with your master ideas. I have requirement that i should either have...
9
by: drhowarddrfine | last post by:
I don't want to use a db manager, like mysql, for such a small database but I'm finding this trickier than I thought and hope someone can provide some guidance. I have a restaurant menu with...
1
by: remya1000 | last post by:
I’m using VB.net 2003 application program. I am trying to do a select statement whereby I'm searching between 2 datetime values that are being stored as datetime. records are stored inside...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.