I need a bit off your help to finish a script.
I want to generate a count report of new *.tif files in a project folder and skip te ones whit a # in them.
I have:
C:\workdir\proj1
C:\workdir\proj2
C:\workdir\#services
//In the proj1 folder are subfolders with tif files. I need to know howmany tif files are added on a dayly base.
//here is my script so far:
#########################################################################
Code: Select all
//make a list of dirs to scan:
Let>GFL_TYPE=1
Let>GFL_SORTTYPE=1
GetFileList>C:\workdir\,strDirList,;
Separate>strDirList,;,dirs
let>l=dirs_count
//Get the date:
day>d
Month>m
Year>y
let>date=%d%-%M%-%Y%
//Open an sheet for the output and set the first free row:
XLOpen>C:\workdir\#Services\xlsheed.xlsx,0,xlBook
XLGetSheetDims>xlBook,Blad2,r,nCo
//Loop trough the dirs and skip the ones with #:
Let>k=0
Repeat>k
Let>k=k+1
Let>r=r+1
Let>dir=dirs_%k%
Position>#,dir,1,nPos,TRUE
if>nPos<>0,skip
// write date and folder name to excel:
XLSetCell>xlBook,Blad2,r,1,%date%,scResult
XLSetCell>xlBook,Blad2,r,2,%dir%,scResult
//Find today Tif files count
[b] #########HELP###########[/b]
// Write %TCount% to excel
XLSetCell>xlBook,Blad2,r,3,%TCount%,scResult
label>skip
Until>k,l
XLSave>xlBook,C:\workdir\#Services\xlsheed.xlsx
XLQuit>xlBook
I have tryed to change this to do my bidding witout any luk.
Code: Select all
VBSTART
Function NewestFile(Folder)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(Folder)
dPrevDate = "0"
For Each oFile In oFolder.Files
If DateDiff("s", dPrevDate, oFile.DateLastModified) > 0 Then
sNewestFile = oFile.Path
dPrevDate = oFile.DateLastModified
End If
Next
NewestFile = sNewestFile
End Function
VBEND
VBEval>NewestFile("C:\workdir\proj1"),filename
Code: Select all
VBSTART
Function Tifcount(Folder)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(Folder)
dPrevDate = "0"
For Each oFile In oFolder.Files
x = DateDiff("d", oFolder.getdetailsOf(File, 3), Now())
If x = 0 Then count = count + 1
If DateDiff("s", dPrevDate, oFile.DateLastModified) > 0 Then
sNewestFile = oFile.Path
dPrevDate = oFile.DateLastModified
End If
Next
Tifcount = count
End Function
VBEND
VBEval>Tifcount("C:\workdir\proj1"),count
mdl>count