Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-18 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found