
Load additional files after multiple file load

aahemm
Hello,
I am trying to load additional files after I have already loaded files and put them in corresponding folders. Here is the full code for my function:
Function/S DoLoadMultipleFiles() Variable refNum string/g outputPaths String fileFilters = "Data Files (*.txt):.txt;" fileFilters += "All Files:.*;" Open /D /R /MULT=1 /F=fileFilters refNum outputPaths += S_fileName if (strlen(outputPaths) == 0) Print "Cancelled" else Variable numFilesSelected = ItemsInList(outputPaths, "\r") Variable i for(i=0; i<numFilesSelected; i+=1) String path = StringFromList(i, outputPaths, "\r") String DataFldrName = ParseFilePath(3, path, ":", 0, 0) if (datafolderexists("root:$DataFldrName") == 1) Print "Datafolder already exists" else NewDataFolder/S root:$DataFldrName // Printf "%d: %s\r", i, path LoadWave/A/D/J/W/K=0/V={"\t"," $",0,0}/L={0,2,0,0,0} path setdatafolder root: endif endfor endif End
Unfortunately, I have issues with the if command, or more specifically with the datafolderexists command.
if (datafolderexists("root:$DataFldrName") == 1)
The datafolderexists command always returns a 0. However in the else-command, when I am trying to create a new folder, it gives me the error that "A data folder of that name already exists at this level". So in the datafolderexists command, it does not know that the data folder exists, but shortly after, it does?! Could anyone please help? Thank you!
Just looking quickly, I think you need
It needs a string but you are passing everything including the dollar as a string. DataFolderExists doesn't find it (because there isn't a folder literally called $DataFldrName).
January 18, 2019 at 01:53 pm - Permalink