Discussion:
Multiple files
(too old to reply)
Salve Håkedal
2010-12-03 13:11:25 UTC
Permalink
I want to run an octave script from the octave command line.

In bash (with a shell script) I could do:
$ script file*
to run the bash script on multiple files.

But it seems I'm not allowed to do the same thing in octave:
octave:1> octavescript "file*"
don't run on all files.

What should I do?
--
Salve
Francesco Potortì
2010-12-04 18:39:31 UTC
Permalink
Post by Salve HÃ¥kedal
I want to run an octave script from the octave command line.
$ script file*
to run the bash script on multiple files.
You must know how to program in bash to have it work.
Post by Salve HÃ¥kedal
octave:1> octavescript "file*"
don't run on all files.
What should I do?
Similarly you must know how to program in Octave to have it work.

What do you need exactly?
Salve Håkedal
2010-12-04 20:27:51 UTC
Permalink
Post by Francesco Potortì
Post by Salve HÃ¥kedal
I want to run an octave script from the octave command line.
$ script file*
to run the bash script on multiple files.
You must know how to program in bash to have it work.
I probably didn't explain myself well enough..
I _know_ how to make scripts that can run on multiple files as
input in bash! I also know how to do the same in octave.
Post by Francesco Potortì
Post by Salve HÃ¥kedal
octave:1> octavescript "file*"
don't run on all files.
What should I do?
Similarly you must know how to program in Octave to have it work.
What do you need exactly?
My question is not related to my octave scripting. My problem is:
With my currently poor knowledge in using octaves command line,
I have to literally type every file name:

octave:1> someoctavescript "file1.wav" "file2.wav" "file3.wav"

I would like to be able to use wildcards on octaves command line
too! But the following don't seem to work:

octave:1> someoctavescript "file*.wav"
--
Salve
Francesco Potortì
2010-12-04 23:14:07 UTC
Permalink
Post by Salve HÃ¥kedal
With my currently poor knowledge in using octaves command line,
octave:1> someoctavescript "file1.wav" "file2.wav" "file3.wav"
I would like to be able to use wildcards on octaves command line
octave:1> someoctavescript "file*.wav"
File name expansion ("globbing") is a feature of Bash and other shells.
You cannot expect Octave or anything else to expand shell wildcards the
way a shell does, so it is not strange that it does not work. However,
some of Octave's functions do globbing on their parameters, like dir,
stat and some others. If you need to do globbing for your own purposes,
try the glob function.
Salve Håkedal
2011-02-23 19:19:05 UTC
Permalink
Post by Francesco Potortì
Post by Salve HÃ¥kedal
With my currently poor knowledge in using octaves command line,
octave:1> someoctavescript "file1.wav" "file2.wav" "file3.wav"
I would like to be able to use wildcards on octaves command line
octave:1> someoctavescript "file*.wav"
File name expansion ("globbing") is a feature of Bash and other
shells. You cannot expect Octave or anything else to expand shell
wildcards the way a shell does, so it is not strange that it does not
work. However, some of Octave's functions do globbing on their
parameters, like dir, stat and some others. If you need to do
globbing for your own purposes, try the glob function.
Thanks for explaining this.

I have tried to find out how to use let's say dir() to run a
functionscript on multiple files, but I give up now. I need more
detailed help!

In my function file sppl.m I now have:

function sppl (varargin)
for i = 1:length (varargin)
file = varargin{i};
...
...
endfunction

This allows me to use the function like this:
octave> sppl "file1.wav" "file2.wav" "file3.wav"
But I would like to rewrite the function to be able to supply only one
argument, to avoid all that typing. Let's say:
octave> sppl "file*.wav"
or, if that's not possible, something like:
octave> files = dir("file*.wav")
octave> sppl files
--
Salve
Salve Håkedal
2011-03-01 19:27:25 UTC
Permalink
Post by Salve HÃ¥kedal
Post by Francesco Potortì
Post by Salve HÃ¥kedal
With my currently poor knowledge in using octaves command line,
octave:1> someoctavescript "file1.wav" "file2.wav" "file3.wav"
I would like to be able to use wildcards on octaves command line
octave:1> someoctavescript "file*.wav"
File name expansion ("globbing") is a feature of Bash and other
shells. You cannot expect Octave or anything else to expand shell
wildcards the way a shell does, so it is not strange that it does not
work. However, some of Octave's functions do globbing on their
parameters, like dir, stat and some others. If you need to do
globbing for your own purposes, try the glob function.
Thanks for explaining this.
I have tried to find out how to use let's say dir() to run a
functionscript on multiple files, but I give up now. I need more
detailed help!
function sppl (varargin)
for i = 1:length (varargin)
file = varargin{i};
...
...
endfunction
octave> sppl "file1.wav" "file2.wav" "file3.wav"
But I would like to rewrite the function to be able to supply only one
octave> sppl "file*.wav"
octave> files = dir("file*.wav")
octave> sppl files
Well, no answer. I finally learned another place:
octave> sppl(glob("*wav"){:})
or
octave> sppl(dir("*wav").name)
Cool!
--
Salve
Continue reading on narkive:
Loading...