Load waves from multiple files and rename
temasi
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:
File1.txt
File2.txt
File3.txt
File4.txt
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:
DoOpenMultiFileDialog()
FilePathToWaveName(path)
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.
Thanks.
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 columnInfoStr = ""
columnInfoStr += "N=Element1_" + fileName + ";"
columnInfoStr += "N=Element2_" + fileName + ";"
LoadWave /J /O /A /Q /B=columnInfoStr /P=$pathName filePath
April 24, 2012 at 09:43 pm - Permalink
Hi,
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.
I'm using:
Function/S OpenMultiFileDialog()
Variable refNum
String message = "Select one or more files"
String outputPaths
String fileFilters = "All Files:.*;"
Open /D /R /MULT=1 /F=fileFilters /M=message refNum
outputPaths = S_fileName
if (strlen(outputPaths) == 0)
Print "Cancelled"
else
Variable numFilesSelected = ItemsInList(outputPaths, "\r")
Variable i
for(i=0; i<code class="language-igor">
...
but there is something wrong with the /B flag...
April 24, 2012 at 11:11 pm - Permalink