We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Opening a file with spaces in the name
Page Index Toggle Pages: 1
Opening a file with spaces in the name (Read 674 times)
Opening a file with spaces in the name
Feb 27th, 2007, 10:58pm
 
I'm having issues opening files with spaces in the name (OS X), using the open() command.  If my file is named "MyFile.ext" the file will open just fine, however if it's named "My File.ext" I can't get it to open.  I even tried to escape the space in the string (like you would do in the terminal of OS X to open the file) but that didn't seem to work either.

Anyone have any ideas here?  Am I doing something wrong?
Re: Opening a file with spaces in the name
Reply #1 - Feb 28th, 2007, 2:28am
 
i'd try either using quotes (the slash-space syntax is specific to the shell), or use the version of open() that takes a string array, since with that, you're making clear that you mean for each individual item to be 'separated', rather than counting on spaces to do the thing.

actually, on osx, it's even messier, since a .app is actually a folder, not an executable. so something like this will work:

open(new String[] { "open", "/Applications/StuffIt Expander.app" });

which uses the osx command line 'open' command to launch the .app file.
Re: Opening a file with spaces in the name
Reply #2 - Feb 28th, 2007, 4:13am
 
That is messy, but it works perfect.  Thanks fry, would have never figured that out on my own.
Page Index Toggle Pages: 1