From: Joao on
Hi all,

I'm having some problems with fprintf function.
I have a loop where some .dat files are generated into a specific directory, and my goal is to create a input.txt file that has in each line the names of the diferent .dat files created. Something like:

input.txt:

1.dat
2.dat
3.dat
4.dat
..
..
..

I've tried to do the logical thing (at least for me) that is a simple dir(*.dat) and write all down in the file. The problem with this is that are written in order, and everything is fine until 10.dat, with the next file being 100.dat instead of 11.dat. My second option, to write the input.txt inside the loop where the .dat files are created. The problem with this options is that the files are created with a specific location:

D:\FTP_files\Skiron metdata\JUL08\day_1timestep_00.dat

and I'm only interested in the filename: day_1timestep_00.dat

Is it possible to use fprintf and print only this filename? Can someone give me a help with this please.

Thanks in advance

Kind regards

João
From: us on
"Joao" <janeiro.jm(a)gmail.com> wrote in message <i3rio4$6o0$1(a)fred.mathworks.com>...
> Hi all,
>
> I'm having some problems with fprintf function.
> I have a loop where some .dat files are generated into a specific directory, and my goal is to create a input.txt file that has in each line the names of the diferent .dat files created. Something like:
>
> input.txt:
>
> 1.dat
> 2.dat
> 3.dat
> 4.dat
> .
> .
> .
>
> I've tried to do the logical thing (at least for me) that is a simple dir(*.dat) and write all down in the file. The problem with this is that are written in order, and everything is fine until 10.dat, with the next file being 100.dat instead of 11.dat. My second option, to write the input.txt inside the loop where the .dat files are created. The problem with this options is that the files are created with a specific location:
>
> D:\FTP_files\Skiron metdata\JUL08\day_1timestep_00.dat
>
> and I'm only interested in the filename: day_1timestep_00.dat
>
> Is it possible to use fprintf and print only this filename? Can someone give me a help with this please.
>
> Thanks in advance
>
> Kind regards
>
> João

a hint:

help fileparts;

us
From: Joao on
"us " <us(a)neurol.unizh.ch> wrote in message <i3rkcl$ksb$1(a)fred.mathworks.com>...
> "Joao" <janeiro.jm(a)gmail.com> wrote in message <i3rio4$6o0$1(a)fred.mathworks.com>...
> > Hi all,
> >
> > I'm having some problems with fprintf function.
> > I have a loop where some .dat files are generated into a specific directory, and my goal is to create a input.txt file that has in each line the names of the diferent .dat files created. Something like:
> >
> > input.txt:
> >
> > 1.dat
> > 2.dat
> > 3.dat
> > 4.dat
> > .
> > .
> > .
> >
> > I've tried to do the logical thing (at least for me) that is a simple dir(*.dat) and write all down in the file. The problem with this is that are written in order, and everything is fine until 10.dat, with the next file being 100.dat instead of 11.dat. My second option, to write the input.txt inside the loop where the .dat files are created. The problem with this options is that the files are created with a specific location:
> >
> > D:\FTP_files\Skiron metdata\JUL08\day_1timestep_00.dat
> >
> > and I'm only interested in the filename: day_1timestep_00.dat
> >
> > Is it possible to use fprintf and print only this filename? Can someone give me a help with this please.
> >
> > Thanks in advance
> >
> > Kind regards
> >
> > João
>
> a hint:
>
> help fileparts;
>
> us

Thanks us,

Much appreciated for the help!