|
I have a few bits of code that may help. I took an approach similar
to Karen, but I used _vbscript_ to get the file listing. This will
allow you to collect file names and extensions that are longer than
8 and 3 characters respectively. The first part is a SP that returns the count and creates a TEMP (or fills if the table already exists) table named FCount: FName NOTE - The file name. FExt NOTE - The file extension, may be NULL FCDate DATETIME - When the file was created. FMDate DATETIME - When the file was last changed FSize INTEGER - The size of the file. FType NOTE - The Windows filetype. You can use FCount to sort/filter the files. The next part is the _vbscript_ that gets the file list. It will only return files, directories are ignored. The last part if another SP I wrote to check for the existence of a table since there was no built in R:Base command and I use the code frequently. I'll paste all three files below. Please let me know if you have any questions. ************************************ -- FileCount.RMD -- Jason Kramer -- 12-19-2011 -- This file is used by the FileCount Stored procedure. It calls the -- getfcount _vbscript_ file and then reads the resulting FCount.csv file into -- the FCount TEMP table, and deletes the FCount csv file. It assumes the -- getfcount and FCount.csv file will be in the same folder as the calling -- database. It requires the name of the directory/folder in which to count -- files as a paramter. Only files are counted, sub directories/folders and -- any files in them are not counted. -- Required Parameter: -- vfctgtfol TEXT - The name of the target folder. -- Return vaule - vfccount INTEGER - the count of files in the folder. -- In addition, FCount is created/filled. -- FCOUNT has the format: -- FName NOTE - The file name. -- FExt NOTE - The file extension, may be NULL -- FCDate DATETIME - When the file was created. -- FMDate DATETIME - When the file was last changed -- FSize INTEGER - The size of the file. -- FType NOTE - The Windows filetype. SET VAR vfctchk INTEGER = NULL SET VAR vfclcmd TEXT = NULL SET VAR vfccount INTEGER = NULL SET VAR vfctchk = (CALL chktbl ('FCount')) IF vfctchk = 0 THEN CREATE TEMP TABLE fcount (fname NOTE,fext NOTE,fcdate DATETIME,fmdate DATETIME,fsize INTEGER,ftype NOTE) ELSE DELETE FROM fcount ENDIF SET VAR vfclcmd = 'LAUNCH getfcount.vbs|' + .vfctgtfol + '|w' &vfclcmd GATEWAY IMPORT CSV fcount.csv REPLACE fcount OPTION SPECIFICATION_FILE_NAME fcount.rgw DELETE fcount.csv SELECT COUNT fname INTO vfccount FROM fcount CLEAR VAR vfctchk,vfclcmd RETURN .vfccount ******************************************** 'getfcount.vbs 'Jason Kramer '12-19-2011 'This _vbscript_ returns the count of all files in a folder as 'the SYTEM environment variable FCount. option explicit Dim iArgCount,folBaseFolder,fleCurFile,fso Dim fleFCount,iExtStart,sFleExt 'Argument count,folder to in which to count files,the current file 'file system object,the output file,the file extention start position,the file extension iArgCount = WScript.Arguments.Count Set fso = CreateObject("Scripting.FileSystemObject") Set fleFCount = fso.CreateTextFile("FCount.csv", True) If iArgCount <> 1 Then MsgBox "Invalid number of arguments." + CStr(iArgCount),vbOkOnly,"ERROR" Else If fso.FolderExists(WScript.Arguments(0)) Then Set folBaseFolder = fso.GetFolder(WScript.Arguments(0)) For Each fleCurFile in folBaseFolder.Files iExtStart = InStrRev(fleCurFile.Name,".") If iExtStart = 0 Then sFleExt = "" Else sFleExt = Right(fleCurFile.Name,Len(fleCurFile.Name)-iExtStart) End If fleFCount.WriteLine fleCurFile.Name + "," + sFleExt + "," + CStr(fleCurFile.DateCreated) + "," + CStr(fleCurFile.DateLastModified) + "," + CStr(fleCurFile.Size) + "," + fleCurFile.Type Next Else MsgBox "Folder not found.",vbOkOnly,"ERROR" End If End If fleFcount.Close MsgBox "Done",vbOkOnly,"DONE" ******************************************* -- CHKTBL Stored Procedure -- Jason Kramer -- 12-12-2011 -- This RMD file is used by the CHKTBL stored procedure to check for the -- exisitance of a table. It takes one parameters, the table name to check -- for, and returns an integer. -- Parameters - 1 required: -- vctname TEXT (Len = 128) - The name of the table to check for. -- Return Value - An integer with one of the following values: -- 0 - No table found. -- 1 - Table found. SET VAR vctretval INTEGER = NULL SELECT COUNT sys_table_name INTO vctretval FROM sys_tables WHERE sys_table_name = .vctname RETURN vctretval *************************************** Jason Kramer University Archives and Records Management 002 Pearson Hall (302) 831 - 3127 (voice) (302) 831 - 6903 (fax) On 12/19/2011 2:10 PM, Michael J. Sinclair wrote:
|
- [RBASE-L] - Re: Counting items in a folder Mike Byerley
- [RBASE-L] - Re: Counting items in a folder Michael J. Sinclair
- [RBASE-L] - Re: Counting items in a folder Mike Byerley
- [RBASE-L] - Re: Counting items in a folder KarenTellef
- [RBASE-L] - Re: Counting items in a folder Michael J. Sinclair
- [RBASE-L] - Re: Counting items in a folder Jason Kramer
- [RBASE-L] - Re: Counting items in a folder Michael J. Sinclair
- [RBASE-L] - Re: Counting items in a folder Mike Byerley
- [RBASE-L] - Re: Counting items in a folder Michael J. Sinclair
- [RBASE-L] - Re: Counting items in a folder Mike Byerley
- [RBASE-L] - Re: Counting items in a folder Michael J. Sinclair
- [RBASE-L] - Re: Counting items in a folder Lawrence Lustig
- [RBASE-L] - Re: Counting items in a folder Mike Byerley
- [RBASE-L] - Re: Counting items in a folder md
- [RBASE-L] - Re: Counting items in a folder Mike Byerley

