SelectFiles

Opens File Open dialog with multiple selection option and returns the list of file paths selected in the dialog. To select multiple files in the dialog, use Ctrl+Mouse_Click or Shift+Mouse_Click

Syntax

SelectFiles(initialDirectory, extension)

Parameters

Parameter

Type

Description

initialDirectory

string

Optional parameter that specifies initial directory for File Open dialog

extension

string

Optional parameter that specifies file extension for File Open dialog.

Return

Returns the list of file paths selected in the File Open dialog. If the user pressed Cancel in File Open dialog, the returned list is empty.

Examples

Python

import nex
# use default initial directory and show all files in dialog
files = nex.SelectFiles()
# use default initial directory and show only .nex5 files in dialog
files = nex.SelectFiles(extension='nex5')
# open files in directory 'C:/MyData' and show only .nex5 files in dialog
files = nex.SelectFiles(initialDirectory='C:/MyData', extension='nex5')

# run the same analysis (Detect Spikes) on all selected files
if files:
   for filePath in files:
      doc = nex.OpenDocument(filePath)
      nex.DeselectAll(doc)
      # select all continuous variables
      contNames = doc.ContinuousNames()
      for name in contNames:
         nex.Select(doc, doc[name])
      # run DetectSpikes analysis
      nex.ApplyTemplate(doc, 'Default\\DetectSpikes')
      # save results in new .nex5 file
      newName = os.path.splitext(filePath)[0] + "_spikes.nex5"
      nex.SaveDocumentAs(doc, newName)
      nex.CloseDocument(doc)