GetFileCount
Returns the number of files that match the file filter.
Syntax
GetFileCount(fileFilter)
Parameters
Parameter |
Type |
Description |
---|---|---|
fileFilter |
string |
File filter specification. Can contain wildcards (*). For example, to get all .nex files in folder C:\Data\, use filter C:\Data\*.nex |
Return
Returns the number of files that match file filter.
Note
In Python, use os.listdir(directory
) function. See example code below.
Examples
The following code will repeat analysis for all .nex files in the folder C:\Data.
Python
import nex
import os
directory = r"C:\Data"
for name in os.listdir(directory):
if name.endswith(".nex"):
fullPath = os.path.join(directory, name)
doc = nex.OpenDocument(fullPath)
if doc:
nex.SelectAllEvents(doc)
# run the analysis, save numerical results and close the file
nex.ApplyTemplate(doc, "Autocorrelograms")
nex.SaveNumResults(doc, fullPath + '.txt')
nex.CloseDocument(doc)
NexScript
% repeat analysis for all .nex files in the folder
filefilter = "C:\Data1\*.nex"
n = GetFileCount(filefilter)
for i=1 to n
name = GetFileName(i)
doc = OpenDocument(name)
if doc > 0
% run the analysis, save numerical results and close the file
ApplyTemplate(doc, "Autocorrelograms")
SaveNumResults(doc, name + ".txt")
CloseDocument(doc)
end
end