Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Dear Monks,

I am trying to write a small Perl script to run an executable file. I want the .exe file to work on the entire contents of a data directory. I’d like to be able to run the final perl program on machines that run Windows XP or Windows 7.

The “System” command doesn’t seem to work for what I am doing and I must include both input and target file names and paths after the executable file name and I am attempting to mix paths with a variable from an array.

The program converts .MID files to .CSV files when run stand alone. Once I have edited the .CSV file I will convert it back to .MID format with another similar file.

The syntax I would use after a command prompt to convert one file at a time, is as follows:

C:\directory\midicsv.exe c:\path\input_file.mid c:\path\target_file.csv

I would like to keep the names of “input_file” and “target_file” the same other than the extension. “Input_file” may be a name that includes the character _

I am trying to convert files in batches. In order to do that I am capturing all the file names in a given data directory to an array, and was hoping to use the file names saved in the array as part of the input_file name string.

Below is what I have written so far. I am getting the following error: “C:midicsvmidicsv.exe’ is not recognized as an internal or external command.” What am I doing wrong?

Can I mix an array variable with a Path? If so can you give me the proper syntax? If not, how can I insert the filenames after the name of the .exe I am calling?

Can I rename all the files to similar names ending in .CSV, and establish an output path to a different directory?

my $directory = 'c:\midicsv\newmidi'; opendir(DIR,$directory); my @files = readdir(DIR); closedir(DIR); #the following line is not truly necessary but I left it in so I could + see that the file names were being captured. foreach(@files){ print $_,"\n";} #this is the line giving me trouble, foreach(@files) {system("c:\midicsv\midicsv.exe", "c:\midicsv\newmidi\ +$_", "c:\midicsv\newcsv\$_");}

In reply to calling an exe and its input and target files by amateur_programmer54

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (4)
    As of 2018-01-21 17:27 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (228 votes). Check out past polls.