<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Hi Philipp</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">This piece of code used to work
      (haven't checked with Scilab 6.1.1). First I ask the user to
      select one file in the directory, then I create a list of all
      files in that directory and read all of them:</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">
      <pre style="font-style: normal; font-size: 12px; font-family: Monospaced;"><span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">units</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">typs</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">nams</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">file</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span> <span style="color:rgb(100,174,100);font-style:italic;">// nams(1) = script file name incl. path</span>
<span style="color:rgb(0,0,0);">fpathname</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">strsplit</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">nams</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(50,185,185);">filesep</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">scriptpath</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">get_absolute_file_path</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">fpathname</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(255,170,0);">$</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>

<span style="color:rgb(50,185,185);">printf</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">Please select a .txt measurement file\n</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">filetoread</span> <span style="color:rgb(0,0,0);">pathtofile</span><span style="color:rgb(74,85,219);">]</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">uigetfile</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">*.txt</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">scriptpath</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">Choose measurement file</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(100,174,100);font-style:italic;">// For a start, assume script file is in the same directory as the data,</span>
    <span style="color:rgb(100,174,100);font-style:italic;">// but don</span><span style="color:rgb(100,174,100);font-style:italic;">'</span><span style="color:rgb(100,174,100);font-style:italic;">t be sure, read pathtofile and use it instead.</span>
<span style="color:rgb(0,0,0);">readfile</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(0,0,0);">pathtofile</span> <span style="color:rgb(92,92,92);">+</span> <span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">\</span><span style="color:rgb(188,143,143);">"</span> <span style="color:rgb(92,92,92);">+</span> <span style="color:rgb(0,0,0);">filetoread</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(160,32,240);">if</span> <span style="color:rgb(50,185,185);">length</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">filetoread</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">></span><span style="color:rgb(188,143,143);">4</span> <span style="color:rgb(160,32,240);">then</span> <span style="color:rgb(100,174,100);font-style:italic;">// one char + .txt expected, i.e. length</span><span style="color:rgb(100,174,100);font-style:italic;">></span><span style="color:rgb(100,174,100);font-style:italic;">4</span>
    <span style="color:rgb(100,174,100);font-style:italic;">// If user doesn</span><span style="color:rgb(100,174,100);font-style:italic;">'</span><span style="color:rgb(100,174,100);font-style:italic;">t select any file, the above check prevents a crash</span>
    <span style="color:rgb(50,185,185);">chdir</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">pathtofile</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(160,32,240);">if</span> <span style="color:rgb(0,0,0);">verbose</span> <span style="color:rgb(160,32,240);">then</span> <span style="color:rgb(50,185,185);">printf</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);"> MSG: File found, thanks!\n</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span> <span style="color:rgb(160,32,240);">end</span></pre>
    </div>
    <div class="moz-cite-prefix">...<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">
      <pre style="font-style: normal; font-size: 12px; font-family: Monospaced;"><span style="color:rgb(100,174,100);font-style:italic;">// Analyze - find all files in the path, who</span><span style="color:rgb(100,174,100);font-style:italic;">'</span><span style="color:rgb(100,174,100);font-style:italic;">s filename is an</span>
<span style="color:rgb(100,174,100);font-style:italic;">// integer, which means - we expect it to be an angle.</span>
<span style="color:rgb(0,0,0);">filelist</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(174,92,176);text-decoration:underline;">listfiles</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">pathtofile</span> <span style="color:rgb(92,92,92);">+</span> <span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">\*.txt</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span></pre>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">...</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">
      <pre style="font-style: normal; font-size: 12px; font-family: Monospaced;"><span style="color:rgb(0,0,0);">imax</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">max</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(50,185,185);">size</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">filelist</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span></pre>
    </div>
    <div class="moz-cite-prefix">...</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">
      <pre style="font-style: normal; font-size: 12px; font-family: Monospaced;"><span style="color:rgb(50,185,185);">printf</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">Loop %i times: </span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">imax</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(160,32,240);">for</span> <span style="color:rgb(0,0,0);">i</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(0,0,0);">imax</span> <span style="color:rgb(160,32,240);">do</span>
    <span style="color:rgb(50,185,185);">printf</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">%i </span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">i</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(100,174,100);font-style:italic;">// Show progress</span>
    <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">path</span> <span style="color:rgb(0,0,0);">fname</span> <span style="color:rgb(0,0,0);">extension</span><span style="color:rgb(74,85,219);">]</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">fileparts</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">filelist</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">i</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
    <span style="color:rgb(160,32,240);">if</span> <span style="color:rgb(50,185,185);">isnum</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">fname</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(160,32,240);">then</span>    <span style="color:rgb(100,174,100);font-style:italic;">// check if fname (a string) contains</span>
        <span style="color:rgb(0,0,0);">d</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(174,92,176);text-decoration:underline;">evstr</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">fname</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>      <span style="color:rgb(100,174,100);font-style:italic;">// a number, and convert to number</span></pre>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">I hope this is inspiring.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Cheers,</div>
    <div class="moz-cite-prefix">Claus</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 27-09-2021 16:50, P M wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CACf7ODvVQZe+=wmVC5mzVpjonxO=KHS9B=0eFKyh622wSZQoLQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Dear All,</div>
        <div><br>
        </div>
        <div>I need to find and list all files of a specific type on my
          hard drive....How to do that in the most elegant way?</div>
        <div><br>
        </div>
        <div>E.g.: <br>
        </div>
        <div><br>
        </div>
        <div>- find all *.txt files in "D:\"</div>
        <div>- also find all '*.txt' files in each sub - directory,
          sub-sub-directory, ..etc<br>
        </div>
        <div>- create a list that stores the absolute path names to the
          *.txt files.</div>
        <div><br>
        </div>
        <div>I am aware of</div>
        <div>- dir</div>
        <div>- findfiles</div>
        <div>- listfiles</div>
        <div>- ls<br>
        </div>
        <div><br>
        </div>
        <div>But they only seem to list the files in a dedicated folder.</div>
        <div><br>
        </div>
        <div>Is there a function, that also searches all sub-folders
          automatically?</div>
        <div><br>
        </div>
        <div>Thank you,</div>
        <div>Philipp<br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>