java to do a batch command

September 27, 2010 at 09:29:20
Specs: Windows XP
im now writing a java program to give my batch program a GUI but my problem is i need my java program to run a batch command and be able to to change parts of the command

the batch command is:
sox %INPUT% %OUTPUT% rate -v 44100

i need to have my java program run this command and change %INPUT% to a file ive selected

i need the file i open to be the %INPUT%
and by pressing either To wma, To mp3 have the program convert the file to whichever is pressed and have the converted file name displayed after converted to:
please help!

here's my java program copy it and run it to have a better idea what i mean:

/*
* SeanyC111
* 27/09/2010
* makes a GUI
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;

public class convert extends JFrame
{
JTextField file = new JTextField(25);
JTextField file_converted = new JTextField(25);
JFileChooser m_fileChooser = new JFileChooser();

convert()
{
file.setEditable(false);
file_converted.setEditable(false);

JButton openButton = new JButton("Open");
JButton wmaButton = new JButton("To wma");
JButton mp3Button = new JButton("To mp3");

openButton.addActionListener(new OpenAction());
wmaButton.addActionListener(new wmaAction());
mp3Button.addActionListener(new mp3Action());

JPanel content = new JPanel();
content.setLayout(new FlowLayout());
content.add(openButton);
content.add(file);
content.add(wmaButton);
content.add(mp3Button);
content.add(new JLabel("Converted To:"));
content.add(file_converted);

this.setTitle("Sox Converter");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(content);
this.pack();
}

class OpenAction implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
int retval = m_fileChooser.showOpenDialog(convert.this);
if (retval == JFileChooser.APPROVE_OPTION)
{
File files = m_fileChooser.getSelectedFile();

file.setText(files.getName());
file_converted.setText(files.getName());
}
}
}

class wmaAction implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{

}
}

class mp3Action implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
System.out.println("mp3");
}
}

public static void main(String[] args)
{
JFrame window = new convert();
window.setVisible(true);
}
}



See More: java to do a batch command

Report •

#1
September 30, 2010 at 06:41:02

Report •
Related Solutions


Ask Question