Re: directory sort




"James Griffin" <epxjmg@xxxxxxxxxxxxxxxx> wrote in message
news:ef16e72.-1@xxxxxxxxxxxxxxxxxxx
> To whom it may concern:
>
> I am getting a problem that doesn't want to go away. Firstly the
> files I have in directory ('C:\Results\asciioutput\t55\') a single
> column of numerical data with many files. The problem I am getting is
> sorting the files into order - both windows and Matlab only views the
> files in order but does not operate on the files in order (the files
> are in the form 1.txt, 2.txt... 10.txt, up to say 345.txt and the
> order will go 90 ....99.txt and then 9_.txt. The code below and
> windows 'view' 'details' sort name order all orcer the files
> correctly however when Matlab executes the program or one looks from
> MSDOS the files are not in sorted order
>
> currdir='C:\Results\asciioutput\t55\';
> d=dir(currdir);
> dd=sort({d.name});
>
> for i=1:length(dd)
> disp( dd{i} );
> end
>
> The above code is used to sort the current directory files however
> the sort is incorrect each time. Can anyone think of another command
> that sorts the directory into name or numerical order but at the
> MSDOS level and windows level.
>
> The rest of the code for the functionality of the program is as
> follows:
>
> %opdir='C:\testcases\OutputFiles\opfd1-14NoBurn1a.txt';
>
> %opdira='C:\testcases\OutputFiles\opfd1-14NoBurn1aFiles.txt'
>
> d=dir(currdir);
> catString = opdir;
> catString1 = opdira;
>
> % read in all files and directories within a directory
> for k=1:length(d)
>
> % get name and file/directory property of entities within a directory
>
> fname=d(k).name;
> dirif=d(k).isdir;
> datastore = 0;
>
> % check for file
> if dirif == 0
> %msgbox('not directory');
> pathread = strcat(currdir, fname)
> data=load(pathread);
> fid=fopen(catString, 'a');
>
> %appending 1024 * 1 double arrays (n files) data and output
> to file
>
>
> fprintf(fid, '%12.8f\n', data);
> st = fclose(fid)
>
> %append files names together and output to file
> fid=fopen(catString1, 'a');
> fprintf(fid, '%s\n', fname);
> st1 = fclose(fid)
>
> % count number of files
> h = h + 1;
>
> % check for directory
> elseif dirif == 1
> %msgbox('directory');
> % count number of directories
> g = g + 1;
> else
> msgbox('no directory or file');
> end
>
> end
>
> I would be grateful if anyone could throw some more light on this
> problem as I would like to move onto more interesting parts of the
> analysis but can not until I have sorted this very odd problem out.
>
> Kind Regards
>
> James

Quickly looking at your code makes me think that 'd' is not
sorted in your second for loop.

You should know that sorting files in MSDOS or Windows just affects the
order they are listed
for you to see. It has no affect on how they are processed internaly, so
to speak.


.



Relevant Pages

  • Re: sort directory
    ... Unfortunately the directory still does not sort in name ... > files in the 1st instance however matlab can still not sort the files ... > like to do is be able to do what windows can but at the file level. ... > also be achievable by Matlab or MSDOS well that's what my logic tells ...
    (comp.soft-sys.matlab)
  • Re: sort directory
    ... > know if there is a command for me use and sort the current directory ... I can order the files in windows explorer however when looking ... > at that same directory in MSDOS it is unordered. ... > program and it can sort automatically each time I run it. ...
    (comp.soft-sys.matlab)
  • directory sort
    ... sorting the files into order - both windows and Matlab only views the ... The above code is used to sort the current directory files however ... catString = opdir; ...
    (comp.soft-sys.matlab)
  • Re: sort directory
    ... I can order the files in windows explorer however when looking ... > at that same directory in MSDOS it is unordered. ... > preferably Matlab as I can just add the code to the already produced ... > program and it can sort automatically each time I run it. ...
    (comp.soft-sys.matlab)
  • sort directory
    ... I know this may sound like a windows or MSDOS problem but does anyone ... extracted in order and this is now a problem for my concatenation ... program and it can sort automatically each time I run it. ...
    (comp.soft-sys.matlab)