[scilab-Users] opening files with unknown names

Mathieu Dubois mathieu.dubois at limsi.fr
Mon Aug 15 18:54:55 CEST 2011


Hello,

Le 15/08/2011 18:08, lukeaarond a écrit :
> I have a folder (called DATABASE) with folders with names of unknown names.
> In those folders are 2-4 files with one of four names (HS.txt, MM.txt,
> PT.txt, or RN.txt). Here is a visual:
>
> DATABASE
>     -ENST0004324
>          -HS.txt
>          -MM.txt
>     -ENST0000054
>          -HS.txt
>          -PT.txt
>          -RN.txt
>
> I need to be able to change directories into a folder and open each text
> file, and then repeat for every folder in DATABASE. However, I cannot use
> chdir() if I do not know the folder names, and cannot use mopen if I do not
> know which text file (or even how many) are in that folder. Any suggestions?
Luckily there are (a lot of) way to list filenames under scilab.
See for instance: ls, dir, findfiles, etc.

Find attached a simple example showing how to visit your DATABASE 
hierarchy (launch it from the directory right above DATABASE). Note that 
it doesn't use chdir() (because you would then need to go back and forth 
your original directory) but instead concatenate different path with 
fullfile.

Another way is to use the find command under every decent UNIX (you can 
probably use this under windows with something like cygwin):
[rep, stat] = unix_g("find . -iname *.txt")
> Thank you.
>
> --
> View this message in context: http://mailinglists.scilab.org/opening-files-with-unknown-names-tp3256145p3256145.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_luke.sce
URL: <https://lists.scilab.org/pipermail/users/attachments/20110815/bf5d6054/attachment.ksh>


More information about the users mailing list