I have to load several waves from different files, and I want to keep the original name of the wave and add the file name to the name of the wave. That way Igor won't show any error for loading waves with the same name.
For example, I have 4 txt files:
Each of them containing the same number of waves with the same name, e.g. Element1, Element2, Element3, Element4, Element5
I need to load the waves and rename them:
Element1_File1 Element1_File2 Element1_File3 Element1_File4
Element2_File1 Element2_File2 Element2_File3 Element2_File4
Element3_File1 Element3_File2 Element3_File3 Element3_File4
Element4_File1 Element4_File2 Element4_File3 Element4_File4
Element5_File1 Element5_File2 Element5_File3 Element5_File4
So far I've managed to load the waves from multiple files and rename them after the file name using the functions below:
I am new new to programming and I've been creating some useful "Frankenstein" procedures by using extracts from old posts. I guess I'll hang to it until I understand how everything really works.
First, you may be better off loading the columns from a given file into a data folder named after that file. To learn about data folders, execute:
DisplayHelpTopic "Data Folders"
Assuming you want to go with your original plan . . .
To control the names of the waves being loaded by LoadWave you need to use the /B flag.
There is an example of this at http://www.igorexchange.com/node/2819. See the second post.
In your case it will look something like this:
String fileName = ParseFilePath(3, filePath, ":", 0, 0) // Get last element of path with extension removed
String columnInfoStr = ""
columnInfoStr += "N=Element1_" + fileName + ";"
columnInfoStr += "N=Element2_" + fileName + ";"
LoadWave /J /O /A /Q /B=columnInfoStr /P=$pathName filePath
Thanks for the answer. I haven't figured out yet how to make it work for multiple files. I forgot to mention that I have more than 100 files and each have more than 50 waves, and their names are totally different... not as in my previous example.
#pragma rtGlobals=1 // Use modern global access method.
String message = "Select one or more files"
String fileFilters = "All Files:.*;"
Open /D /R /MULT=1 /F=fileFilters /M=message refNum
outputPaths = S_fileName
if (strlen(outputPaths) == 0)
Variable numFilesSelected = ItemsInList(outputPaths, "\r")
for(i=0; i<numFilesSelected; i+=1)
String path = StringFromList(i, outputPaths, "\r")
// Get just the fileName but with the extension remove.
String name = ParseFilePath(3, path, ":", 0, 0)
name = CleanupName(name, 0)
// Get string to pass to LoadWave /B flag to set wave name
columnInfo = "N='%s';" + name +";"
Printf "%d: %s\r", i, path
return outputPaths // Will be empty if user canceled
... but there is something wrong with the /B flag...
Back to top