#133310 - 2005-02-02 09:50 PM
GetFileDate on a Folder
|
AlexW
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
|
|
|
|
#133312 - 2005-02-03 12:32 AM
Re: GetFileDate on a Folder
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
See if fnGetFolderProp() will get you what you need.
|
|
Top
|
|
|
|
#133314 - 2005-02-03 09:43 PM
Re: GetFileDate on a Folder
|
AlexW
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
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
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
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
|
|
|
|
#133319 - 2005-02-05 07:50 AM
Re: GetFileDate on a Folder
|
Allen
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.
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
|
|
|
|
#133322 - 2005-02-13 02:53 PM
Re: GetFileDate on a Folder
|
AlexW
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
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
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 837 anonymous users online.
|
|
|