Loading an entire directory

Is there anyway instead of loading one file at a time and then having it do these steps, for it to load an entire directory, taking each file through these steps before it moves to the next file in the directory?

Function CCNLoader()            
// Loads one file at a time, edits time wave, adds them to the proper waves, then deletes them
   
   
    do
        LoadWave/J/D/A=wave/K=0/L={4,6,0,0,0}
        if (V_flag == 0)        // Break if user hit the cancel button.
            break
        endif


        GetFileFolderInfo/Z S_path+S_fileName
        if( V_Flag == 0 && V_isFile )   // file exists
   
       
        wave wave0            // changes time data -> Time and Date data
        wave0=X
        wave0+=V_modificationDate
   
    endif
   
        Concatenate/NP {wave0}, TimeAll
        Concatenate/NP {wave1}, CurrentSSAll

        KillWaves wave0,wave1
               
        if (wAVEExists (wave48))   //check command history to see if there were alarms
            Killwaves wave48
            print "ALARM!!!"
        else
            print "No Alarms"  
        endif
           
    while(1)



End



Files are recorded like this every hour


CCN data YYMMDDhhmmss.csv
CCN data 080601125425.csv
CCN data 080601135426.csv
CCN data 080601145427.csv
astrotool wrote:
Is there anyway instead of loading one file at a time and then having it do these steps, for it to load an entire directory, taking each file through these steps before it moves to the next file in the directory?

I don't understand your question. But I think the answer to your question is no. As far as I know, there's not really a way in any programming environment to load an entire directory at once, because directories are a collection of files and therefore each file must be loaded individually.

Maybe I'm not understanding your question.
astrotool wrote:
Is there anyway instead of loading one file at a time and then having it do these steps, for it to load an entire directory, taking each file through these steps before it moves to the next file in the directory?


Consider that you have two functions ...

Function/S LoadMyFile(theFile)
   string theFile

   <load the file>
   return (string list of waves loaded or "" if no waves loaded)
end

Function DoMyOperation(ListofWaves)
   string ListofWaves

   <do what you need to do on each wave(s) in the string list itsWaves>
   return 0
end


You can do one of the following:

Function DoItAll_A(theList)
    string theList
   
    // theList = a string listing of the full path to all files in a certain directory

    ...

    // LOOP ON (load + operate)

    for (ic=0;ic<nt;ic+=1)
       sprintf theFldr, "root:MyFolder%d", ic
       NewDataFolder/O/S $theFldr
       theFile = StringFromList(ic,theList)
       itsWaves = LoadMyFile(theFile)
       if (strlen(itsWaves)==0)
          break
       endif
       DoMyOperation(itsWaves)
    endfor
    return 0
end

Function DoItAll_B(theList)
    string theList
   
    // theList = a string listing of the full path to all files in a certain directory

    ...

   // LOOP ON (load)

    for (ic=0;ic<nt;ic+=1)
       sprintf theFldr, "root:MyFolder%d", ic
       NewDataFolder/O/S $theFldr
       theFile = StringFromList(ic,theList)
       itsWaves = LoadMyFile(theFile)
       if (strlen(itsWaves)==0)
          break
       endif
    endfor

   // LOOP ON (operate)

    for (ic=0;ic<nt;ic+=1)
      sprintf theFldr, "root:Myfolder%d", ic
      SetDataFolder $theFldr
      itsWaves = WaveList("*",";","")
      DoMyOperation(itsWaves)
    endfor
    return 0
end


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
astrotool wrote:
Is there anyway instead of loading one file at a time and then having it do these steps, for it to load an entire directory, taking each file through these steps before it moves to the next file in the directory?


Yes. Execute this to see the relevant help:

DisplayHelpTopic "Loading All of the Files in a Folder"