Curious
(Getting the hang of it)
2010-03-16 09:12 AM
Using dirlist.udf to get all dirs in location, then check creation date

Hello.

I am using dirlist to get an array to check all dirs in a given location. In all dirs returned, I need to extract creation month, date etc.

The script is something like this:

 Code:
Call "udf\dirlist.udf"

$Files = Dirscan('\\fmtefil1\tsprofiler', 1) ; return a list of all files with complete paths
			
For Each $file In $Files
			 
'Filnavn: $file' ?		

			

$check = GetFileTime('$file',"1")

$Createyear = SubStr("$check",1,4)
$CreateMonth = SubStr("$check",6,2)
$CreateDate = SubStr("$check",9,2)
'Month: $CreateMonth' ?
'Date : $CreateDate' ?
;then some checking will be done
---
---
Next


All dirs return as I want, but I am not able to extract the $CreateYear, month and date, which is essential to process the dirs further.

I am doing something wrong, but can't seem to find out what it is.

Anyone??

Regards
/J


Mart
(KiX Supporter)
2010-03-16 09:57 AM
Re: Using dirlist.udf to get all dirs in location, then check creation date

In your script you get the folder name but not the full path. The DirScan UDF will return the full path if you sue 0 as the second parameter. You have it set to 1, this will return the folder name but not the path so GetFileTime will fail because it cannot find the folder.

A few comment:
  • Do not use variables inside quotes. The script below is altered to have all variables outside any quotes.
  • You use single and double quotes for the same purpose. Although they match and therefore should not cause any problems it would be better to use single or double quotes and not mix them in one and the same script.


The script below works great for me (with a different folder to scan ;\) ).
 Code:
Break on

$Files = Dirscan("\\fmtefil1\tsprofiler", 1) ; return a list of all files with complete paths
			
For Each $file in $Files 
	"Filnavn: " + $file ?		
	$check = GetFileTime($file,"1")
	$Createyear = SubStr($check,1,4)
	$CreateMonth = SubStr($check,6,2)
	$CreateDate = SubStr($check,9,2)
	"Month: " + $CreateMonth ?
	"Date : " + $CreateDate ?
	;then some checking will be done
Next

Sleep 5


Curious
(Getting the hang of it)
2010-03-19 04:43 PM
Re: Using dirlist.udf to get all dirs in location, then check creation date

I was sure that I posted a post just minutes after, because I saw what I had been doing wrong (allthough the script surely can be improved), but I must have forgotten to post it.

But tnx anyway Mart, appreciating you are correcting me, have been unsure of when to use the " and when to use the '

And.. I was using Dirscan, because I only need to check the Dirs in the directory of choosing.

Tnx

Regards /J