I have need of a utility that will count files matching a disk file name pattern
.
Does any of you know a smart thingy?
//Henrik P
In article <3a68f726-ce63-40e5...@googlegroups.com>,
kilg...@gmail.com says...
I have need of a utility that will count files matching a disk file name pattern
.
Does any of you know a smart thingy?
//Henrik PThis gets you most of the way there
#pragma fieldalign shared2 FILEINFO_DEF
typedef struct FILEINFO_DEF
{
int64_t modtime;
int64_t createts;
int64_t lastopents;
int64_t eof;
unsigned short priext;
unsigned short secext;
short maxext;
short extalloc;
short userid;
short filecode;
short filetype;
short reclen;
short blocklen;
short progid;
short clearonpurge;
char security[4];
short licensed;
short audited;
short createoptions;
short fileisopen;
short crashopen;
short broken;
short corrupt;
short numpartitions;
short ossfile;
short xpartition;
short securitytype;
short format;
short numaltkeys;
short sqlprogram;
short sqlvalid;
struct
{
short devtype;
short subtype;
short objecttype;
short filetype;
short filecode;
} typeinfo;
short filename_len;
char filename[48];
} FILEINFO_DEF;
struct
{
int64_t bytes;
int64_t files;
int64_t files_scanned;
int64_t filesets;
} total;
/*-------------------------------------------------------------------------* * * *-------------------------------------------------------------------------*/ short FI_listfiles(char *filename, short filename_len)
{
short erc = 0;
short search_id = 0;
struct
{
short devtype;
short subtype;
short objtype;
short filetype;
short filecode;
} typeinfo;
FILEINFO_DEF fi;
if (detail)
{
sprintf(message, "Processing pattern %s", filename);
printmessage(message);
}
erc = FILENAME_FINDSTART_(&search_id,
filename,filename_len,
-1, /* resolve vol to filename */
3, /* disc devices */
-1, /* devicesubtype */
0, /* options */
filename, 0);
if (erc)
{
sprintf(message, "FILENAME_FINDSTART_ error %d on %s",
erc, filename);
printmessage(message);
return(0);
}
while (erc != 1)
{
erc = FILENAME_FINDNEXT_(search_id,
filename, 48, &filename_len,
(short *)&typeinfo,
0);
if (erc)
{
break;
}
filename[filename_len] = 0;
memset(&fi, 0, sizeof(fi));
erc = FI_getfileinfo(filename,filename_len, &fi);
if (erc == 0)
{
total.files_scanned = total.files_scanned + 1;
process_file(&fi);
}
} /* while */
FILENAME_FINDFINISH_(search_id);
return(0);
} /* FI_listfiles */
How about this?[#argument F
?tacl macro
#frame
[#DEF fileCount TEXT |BODY| 0]
[#DEF countRoutine ROUTINE
|BODY|
[#loop |WHILE| [#more]
|DO| #set fileCount [#compute [fileCount] +
ILENAME]]
]
]
countRoutine [#filenames %*%]
#output [fileCount] files counted
#unframe
Jon Marcus
#filenames *.*#filenames *.*
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 64:00:14 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,761 |