#40954 - 2003-06-02 10:54 PM
Dir () results order?
|
rliang
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
|
|
|
|
#40956 - 2003-06-02 11:16 PM
Re: Dir () results order?
|
Sealeopard
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
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
|
|
|
|
#40959 - 2003-06-03 03:34 AM
Re: Dir () results order?
|
rliang
Fresh Scripter
Registered: 2003-03-10
Posts: 18
|
Excellent! COMPAREFILETIMES will do the trick. Thanks
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 764 anonymous users online.
|
|
|