Page 1 of 1 1
Topic Options
#40954 - 2003-06-02 10:54 PM Dir () results order?
rliang Offline
Fresh Scripter

Registered: 2003-03-10
Posts: 18
Does anybody know when a Dir() function returns a matching result whether the item found is based on date, name, or some other criteria? I have a certain file pattern to search for, when multiple instances are found I'd like to find out what process was applied to the search engine. Thanks
Top
#40955 - 2003-06-02 11:11 PM Re: Dir () results order?
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I want to say file creation date.... but i am not 100% sure on this.
Top
#40956 - 2003-06-02 11:16 PM Re: Dir () results order?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I'd rather say in the order the filenames were written into the file (allocation) table, wich not necessarily need to correspond with the fielcreation time. However, as it is entirely up to the file system how to store these things, I would just forget worrying about this. What happens aftrer defragging a drive? what happens when you delete a file and rewcreate it right away, will the fileentry written into the same location or a different one? What is the filesystem, FAT, FAT32, NTFS, NTFS5, Linux? Why would you need this anyway?

You can always retrieve the filedates via KiXtart.

Maybe you should explain the underlying problem.
_________________________
There are two types of vessels, submarines and targets.

Top
#40957 - 2003-06-02 11:29 PM Re: Dir () results order?
rliang Offline
Fresh Scripter

Registered: 2003-03-10
Posts: 18
Jens,

I'm written a basic inventory system which tracks workstation info into a master file (COMPUTERS.CSV) as well as records individual workstation files (WRKSTN1.TXT). My procedures update the master and individual workstation file if they haven't been updated for at least 7 days. I found that as people changed workstation names the old individual files remained (WRKSTN1.TXT, RIXWS.TXT, LAPTOP.TXT) even though they all referred to the same workstation. I've since changed my naming scheme to reflect the MAC address of the NIC card, (eg WRKSTN1.00B0D6C9181A.TXT). Now in my clean-up process I want to find any previous instances but I want do delete all but the most recent.

Anyways I think I solved my dilima with:
$hw_dir="S:\Inventory\Hardware\"
$addrpattern=$hw_dir+"*."+@ADDRESS+".txt"
$wkstxt=$hw_dir+@WKSTA+"."+@ADDRESS+".txt"
$delfile=$hw_dir+Dir("$addrpattern")
WHILE $delfile<>$hw_dir
IF $delfile<>$wkstxt
DEL $delfile
ENDIF
$delfile=$hw_dir+Dir()
LOOP

This may not be elegant, but for my purposes I got it working.

I was somewhat curious what criteria Dir() used to return a search value.

Thanks!

Top
#40958 - 2003-06-02 11:32 PM Re: Dir () results order?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
That's what GETFILETIME and COMPAREFILETIMES are for.
_________________________
There are two types of vessels, submarines and targets.

Top
#40959 - 2003-06-03 03:34 AM Re: Dir () results order?
rliang Offline
Fresh Scripter

Registered: 2003-03-10
Posts: 18
Excellent! COMPAREFILETIMES will do the trick. Thanks
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.058 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org