We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello!
I am attempting to launch a batch script from processing using the launch()
command. After much experimentation I got it to work but I now need to make it user friendly. I am asking the user to find their own install of ffmpeg to run.
void setup(){
selectInput("Please find ffmpeg.bat", "launchStuff");
}
void launchStuff(File file){
String filePath = file.getPath();
launch("cmd /c start /w " + filePath);
}
The problem is that ffmpeg tends to download in Program Files (on Windows), which means that there are spaces in the file path. This causes the error "C:/Program"
cannot be found. How do I deal with these spaces?
Thank you!
Answers
Maybe replace() method can help: http://docs.Oracle.com/javase/8/docs/api/java/lang/String.html#replace-java.lang.CharSequence-java.lang.CharSequence-
String filePath = file.getPath().replace("/", "\\");
String filePath = file.getPath().replace('/', File.separatorChar);
I just tried it...I got the same error. The problem is the spaces in the "Program Files" folder name. But thank you!
Maybe:
launch("cmd /c start /w " + '"' + filePath + '"');
? :-??Interesting...so that got command prompt to launch (YAY) but it did not run ffmpeg. Super strange...
Do you by chance know how to feed command prompt commands once it is open via processing?
According to launch()'s reference: https://processing.org/reference/launch_.html
It returns an object of type Process: http://docs.Oracle.com/javase/8/docs/api/java/lang/Process.html
That's as far as I know, sorry. I-)
No, that's super helpful. Thank you!