GetFileName

Returns the file name for the specified index after GetFileCount() was called.

Syntax

GetFileName(index)

Parameters

Parameter

Type

Description

index

number

Index of the file in the file list created by the last call to GetFileCount()

Return

Returns the file name (the full path of the file) for the specified index after GetFileCount() was called.

Note

In Python, use os.listdir(directory) function. See example code below.

Examples

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