Results 1 to 5 of 5

Thread: Run a program on multiple sets of inputs from command line

  1. #1
    Join Date
    Mar 2011
    Location
    South Africa
    Beans
    137
    Distro
    Kubuntu 11.10 Oneiric Ocelot

    Run a program on multiple sets of inputs from command line

    Hi (I hope I'm posting this thread in the right section)

    I've written a program which takes as input a midi file and output multiple csv lines

    I know in Bash I can do something like
    Code:
     touch test{0,1,2}
    to create multiple files

    The problem is that it doesn't seem to work when I do something like:
    Code:
    ./myProgram midi{0,1,2,3,4} > output{0,1,2,3,4}
    Basically I want it to take in multiple midi files, and output multiple text files.
    boink.

  2. #2
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Run a program on multiple sets of inputs from command line

    You could do it with a for-loop or similiar. I'm just trying to think of a way of keeping the filenames unique. I think this one ends up with .midi.csv extension.

    Code:
    for $files in *.midi; do ./myprogram > $files.csv
    or you could do it in-program with a for-loop which iterates over stdin until done.

    Somebody probably has a better idea.

  3. #3
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,364
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Run a program on multiple sets of inputs from command line

    I've written a program which takes as input a midi file and output multiple csv lines
    1 midi = multiple csv files? so how does this work exactly? details would be nice because i have some trouble visualizing it.

  4. #4
    Join Date
    Mar 2011
    Location
    South Africa
    Beans
    137
    Distro
    Kubuntu 11.10 Oneiric Ocelot

    Re: Run a program on multiple sets of inputs from command line

    Quote Originally Posted by Vaphell View Post
    1 midi = multiple csv files?
    1 midi = 1 csv file. That's what I'd like. At the moment If I run the program, it prints to stdout, which I then just redirect to a txt file.

    All my midi files are similarly named: Beat0.mid, Beat1.mid....
    and for each midi file I'd like to have a csv file corresponding to that midi file: data0.txt, data1.txt....

    I'm just wondering how I'd do it so that I wouldn't have to type out many statements:
    Code:
    ./myProgram Beat0.mid > data0.txt
    ./myProgram Beat1.mid > data1.txt
    ./myProgram Beat2.mid > data2.txt
    .
    boink.

  5. #5
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,364
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Run a program on multiple sets of inputs from command line

    for loop is your friend then

    Code:
    for i in {1..5}; do ./myProgram Beat$i.mid > data$i.txt; done

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •