Page 1 of 1 1
Topic Options
#133310 - 2005-02-02 09:50 PM GetFileDate on a Folder
AlexW Offline
Fresh Scripter

Registered: 2005-02-02
Posts: 7
Like in vbscript, i expected the function GetFileDate to work on folders also, but is doesn't. I tried different syntaxes like GetFileDate("$FolderPath") or GetFileDate("$FolderPath\") or GetFileDate("$FolderPath\.") none of them seems to work. Does anyone know if this is possible with GetFileDate?.

(And yes i am able to build my own workaround, thats not the answer i am expecting...)

If not, is this simple to realize in the next release Ruud?

Top
#133311 - 2005-02-02 10:05 PM Re: GetFileDate on a Folder
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
AFAIK, there is no built-in function called GetFileDate(). JIC it was a hidden feature, I even tried it in 4.23 but got an error.
Quote:

ERROR : unknown command [getfiledate]!
Script: C:\KiXscripts\test.kix
Line : 2

C:\KiXscripts>


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133312 - 2005-02-03 12:32 AM Re: GetFileDate on a Folder
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
See if fnGetFolderProp() will get you what you need.
Top
#133313 - 2005-02-03 01:45 AM Re: GetFileDate on a Folder
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
However, there is a GETFILETIME() function documented in the Kixtart Manual for reading file times.
_________________________
There are two types of vessels, submarines and targets.

Top
#133314 - 2005-02-03 09:43 PM Re: GetFileDate on a Folder
AlexW Offline
Fresh Scripter

Registered: 2005-02-02
Posts: 7
Stupid , i meant to say GetFileTime(), sorry guys

I don't want to rely on windows scripting, because the script i want to use it for need to run on 9x-XP. On 95 wsh is not installed by default, neighter on NT4. I need a 100% fool proof check, without "thouching" the old operating system and install wsh first.

Top
#133315 - 2005-02-03 11:43 PM Re: GetFileDate on a Folder
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I created a DIRDATE() UDF. Its output mimics that of GETFILETIME. Its only requirement is the command processor. I haven't tested it with Win9x machines, but I think it should work. The board was having trouble with this line: $details=split($line,"<" + "DIR" + ">") so I had to break up the string.

Let me know if this helps.

Code:
  

dirdate("C:\Windows")

function dirdate($dir)
dim $temp,$parentdir,$childdir,$line,$datetime,$date,$time,$details
$temp="%temp%\dirdate.tmp"
if exist($dir)
if right($dir,1)="\"
$dir=substr($dir,1,len($dir)-1)
endif
$parentdir=substr($dir,1,instrrev($dir,"\"))
$childdir= substr($dir,instrrev($dir,"\")+1)
shell '%comspec% /c dir /ad "' + $parentdir + '" > "$temp"'
if open(1,$temp)=0
$line=readline(1)
while @error=0 and $dirdate=0
$details=split($line,"<" + "DIR" + ">")
if ubound($details)>0
if ucase(trim($details[1]))=ucase($childdir)
$datetime=trim($details[0])
$date=left($datetime,10)
$date=split($date,"/")[2] + "/" + split($date,"/")[0] + "/" + split($date,"/")[1]
$time=right($datetime,8)
if right($time,2)="AM"
$time=left($time,5) + ":00"
else
$time=left($time,5)
$time="" + (val(split($time,":")[0])+12) + ":" + split($time,":")[1] + ":00"
endif
$dirdate=$date + " " + $time
endif
endif
$line=readline(1)
loop
endif
$=close(1)
else
exit 2
endif
endfunction

_________________________
(... better days ahead)

Top
#133316 - 2005-02-04 11:04 PM Re: GetFileDate on a Folder
AlexW Offline
Fresh Scripter

Registered: 2005-02-02
Posts: 7
Thx Allen for your work. I more or less created the same myself (thats why i made the remark in the org post.)
But i not really like wrappers, parsers like this, embedded function whould be much nicer, like in Vb.

Top
#133317 - 2005-02-04 11:07 PM Re: GetFileDate on a Folder
AlexW Offline
Fresh Scripter

Registered: 2005-02-02
Posts: 7
I forgot the main problem with this. I want to hav ea reliable way to do this on whatever language version of windows. With this kin dof workareoun di need to sort out the correct characters to split with, like you doing with "/"
Top
#133318 - 2005-02-05 12:07 AM Re: GetFileDate on a Folder
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I understand your problem, and you are right, it would be nice for this to work in-build. Just curious, have you tried the DIRDATE function?

I'm willing to modify this to work with other flavors of Windows, but if you are not going to use it, then I'm less likely to do so, because lets face it, Win9x is just about history.
_________________________
(... better days ahead)

Top
#133319 - 2005-02-05 07:50 AM Re: GetFileDate on a Folder
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I got bored ... and found a Win98 machine to test with. So as of right now, I've tested the version below on WinXP, and Win98. Anyone have a W2k, NT4, or Win95 box and be willing to test.

Code:
 

? dirdate("C:\windows")

function dirdate($dir)
dim $temp,$parentdir,$childdir,$line,$datetime,$date,$time,$details,$datearray[2]
$temp="%temp%\dirdate.tmp"
if exist($dir)
if right($dir,1)="\"
$dir=substr($dir,1,len($dir)-1)
endif
$parentdir=substr($dir,1,instrrev($dir,"\"))
$childdir= substr($dir,instrrev($dir,"\")+1)
shell '%comspec% /c dir /ad "' + $parentdir + '" > "$temp"'
if open(1,$temp)=0
$line=readline(1)
while @error=0 and $dirdate=0
if @inwin=1
$details=split($line,"<" + "DIR" + ">")
if ubound($details)>0
if ucase(trim($details[1]))=ucase($childdir)
$datetime=trim($details[0])
$date=left($datetime,10)
$date=split($date,"/")[2] + "/" + split($date,"/")[0] + "/" + split($date,"/")[1]
$time=right($datetime,8)
if right($time,2)="AM"
$time=left($time,5) + ":00"
else
$time=left($time,5)
$time="" + (val(split($time,":")[0])+12) + ":" + split($time,":")[1] + ":00"
endif
$dirdate=$date + " " + $time
endif
endif
else
if right(ucase(trim($line)),len($childdir))=ucase($childdir)
$date=substr(right($line,16+len($childdir)),1,8)
$datearray=split($date,"-")
if val($datearray[2])<85
$datearray[2]="20" + $datearray[2]
else
$datearray[2]="19" + $datearray[2]
endif
$date=$datearray[2] + "/" + $datearray[0] + "/" + $datearray[1]
$time=substr(right($line,7+len($childdir)),1,6)
if right($time,1)="a"
$time=left($time,5) + ":00"
else
$time=left($time,5)
$time="" + (val(split($time,":")[0])+12) + ":" + split($time,":")[1] + ":00"
endif
$dirdate=$date + " " + $time
endif
endif
$line=readline(1)
loop
endif
$=close(1)
else
exit 2
endif
endfunction

_________________________
(... better days ahead)

Top
#133320 - 2005-02-05 03:04 PM Re: GetFileDate on a Folder
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Actually, WSH 1.0 is installed on Windows 95 and NT 4.0 systems. See this link...

Upgrading Windows Script Host

...and the File System Object has been included since 1.0.

Top
#133321 - 2005-02-06 01:47 PM Re: GetFileDate on a Folder
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Can give it a go on NT4 tomorrow when I’m back at work.
Although we are migrating to Win2K3 and XP there are still some NT4 boxes in use for now

I think it’s very useful functionality getting the date of a folder.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#133322 - 2005-02-13 02:53 PM Re: GetFileDate on a Folder
AlexW Offline
Fresh Scripter

Registered: 2005-02-02
Posts: 7
I not really agree with your statement.
wsh is not present when you never updated IE. On 9x WSH came with IE or as a seperate package and was never nativaly present in w9x (build 950 and i even think 1111), also first build of NT4 without updating IE didn't have WSH on board.

Why do i need all this for. I am in the migration of user data business and new OS deployments. So 9x is old yes! i see them on monthly base at businesses who not really care about support and have them still up an running.

Top
#133323 - 2005-02-24 07:42 PM Re: GetFileDate on a Folder
AlexW Offline
Fresh Scripter

Registered: 2005-02-02
Posts: 7
The following text is present in script56.chm, this more or less proofs my statement.

The following table lists the version of Windows Script Host implemented by Microsoft host applications.

Host Application 1.0 2.0 5.6
Microsoft Windows 98 x
Microsoft Windows NT 4 Option Pack x
Microsoft Windows 2000 x

Top
Page 1 of 1 1


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

Who's Online
0 registered and 837 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.063 seconds in which 0.023 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