473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DateLastAccessed Problem

sb
I'm trying to come up with a simple script to iterate through a bunch of
images in a directory and delete the ones that haven't been viewed in x
number of months. I thought "DateLastAccessed" would be the way to go but
it seems to have a rather strict interpretation of what consists of "access"
If I view a file, has it not been "accessed"? Not according to my script.
No matter how many times I view an image, the value stays the same...

Can anyone point me in the right direction here?
Jul 19 '05 #1
2 1849
> Can anyone point me in the right direction here?

You could have all your image path's pointing to an asp page, which then
records the image name and date in a database and then displays the image.

This example might get you started...
http://www.aspfaq.com/2276

-Randy
Jul 19 '05 #2


This is what I wrote (with some help from the users at
developersdex.com). It queries a directory, compiles a list that is x
number of days old, deletes the files, emails you a copy of the list of
files, and deletes the file list (using a couple of batch files that
could easily be worked in).

====================
Option Explicit

Dim oFS, sSourceDir, nDays, nTotal, sFileList

Set oFS = WScript.CreateObject("Scripting.FileSystemObject")

'set nDays to be the number of days since last accessed
'(6 months is 180 days)
nDays = 180

'Put your directory you want to query as the sSourceDir
'sSourceDir = "\\server\users\JohnDoe"

Call FindOldFiles(oFS.GetFolder(sSourceDir))

If nTotal > 1 Then

' MsgBox "WARNING: Time to archive files!" & vbCrlf & _
'
"------------------------------------------------------------------" &
vbCrlf & vbCrlf & _
' "You have " & nTotal & " file(s) that need to be archived!"
& vbCrlf & sFileList, vbInformation ,"Archive Check"

'------------------------------
' Write out results to log file
Dim FileSystemObject, TextStream

Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set TextStream = FileSystemObject.CreateTextFile("C:\oldfiles.LOG",
True)

TextStream.WriteLine ("This script has deleted " & nTotal & " file(s)
from some folder on some server") & vbCrlf & _
"--------------------------------------------------" & vbCrlf & _
sFileList ', vbInformation, "Archive Check"

TextStream.Close

'------------------------------
' Email results

Dim stdout, shell
Dim cmd
function ExecCmd(cmdline)
set stdout = wscript.stdout
set shell = createobject("wscript.shell")
set cmd = shell.exec(cmdline)
do until cmd.status = 1 : wscript.sleep 5 : loop
ExecCmd = cmd.stdout.readall
End Function

ExecCmd ("oldfile.bat")
'----------------------
'
' oldfile.bat
'
' blat c:\oldprofiles.log -s "Old Profiles that have
' not been accessed in 180 days on SomeServer"
' -t us******@somedomain.com
' del c:\oldprofiles.log
'
' -------------------------
Else
MsgBox "No files need to be archive", vbInformation ,"Archive Check"
End If

'

WSCript.Quit

'---------------------
Sub FindOldFiles(oFolder)
Dim oFile, oSubFolder

For Each oFile In oFolder.Files
If IsOlder(oFile, nDays) Then
nTotal = nTotal + 1
sFileList = sFileList & oFile.Path & vbCrlf
'--------
'
' Deletes old files
'
'--------
oFS.GetFile (oFile)
oFS.DeleteFile (oFile)
'--------
'
' Comment out the lines above if do not want to delete
'
'--------
End If
Next
For Each oSubFolder In oFolder.SubFolders
Call FindOldFiles(oSubFolder)
Next

End Sub

'---------------------
Function IsOlder(oFile, nDays)
IsOlder = False
If DateDiff("d", oFile.DateLastAccessed, Now) > nDays Then IsOlder =
True
End Function
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

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

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
0
by: Horhayson | last post by:
I have seen the problem, too. I have a script running against an install directory containing Windows service packs, etc. The script has reported back that WinXP Service Pack 1a has not been...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.