comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Spaces in Mac file names
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Spaces in Mac file names [message #83991] Sat, 13 April 2013 21:19
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/13/13 12:33 PM, Jeff N. wrote:
> On Saturday, April 13, 2013 1:30:22 PM UTC-4, kagol...@lbl.gov wrote:
>> Regarding spaces in Mac file and directory names: I know this is an old topic, but is there a generally accepted method, or a library function in someone's IDL library, to take a file name as input and output ac copy with the spaces escaped properly with backslashes?
>>
>>
>>
>> In other words, take
>>
>> /this/directory/has spaces/youknow.txt
>>
>> and output
>>
>> /this/directory/has\ spaces/youknow.txt
>>
>>
>>
>> I need this for a spawn command to work on arbitrary files. Thanks!
>
> I usually do this:
>
> ENVI> path = '/this/directory/has spaces/youknow.txt'
> ENVI> print, strjoin(strsplit(path, ' ', /extract), '\ ')
> /this/directory/has\ spaces/youknow.txt
>

Careful, multiple spaces won't be treated correctly. Use /PRESERVE_NULL:

IDL> path = '/this/directory/has spaces/you know.txt'
IDL> print, strjoin(strsplit(path, ' ', /extract), '\ ')
/this/directory/has\ spaces/you\ know.txt
IDL> print, strjoin(strsplit(path, ' ', /extract, /preserve_null), '\ ')
/this/directory/has\ spaces/you\ \ know.txt

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
Re: Spaces in Mac file names [message #83992 is a reply to message #83991] Sat, 13 April 2013 11:33 Go to previous message
jeffnettles4870 is currently offline  jeffnettles4870
Messages: 111
Registered: October 2006
Senior Member
On Saturday, April 13, 2013 1:30:22 PM UTC-4, kagol...@lbl.gov wrote:
> Regarding spaces in Mac file and directory names: I know this is an old topic, but is there a generally accepted method, or a library function in someone's IDL library, to take a file name as input and output ac copy with the spaces escaped properly with backslashes?
>
>
>
> In other words, take
>
> /this/directory/has spaces/youknow.txt
>
> and output
>
> /this/directory/has\ spaces/youknow.txt
>
>
>
> I need this for a spawn command to work on arbitrary files. Thanks!

I usually do this:

ENVI> path = '/this/directory/has spaces/youknow.txt'
ENVI> print, strjoin(strsplit(path, ' ', /extract), '\ ')
/this/directory/has\ spaces/youknow.txt
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Spaces in Mac file names
Next Topic: COST atmospheric correction IDL code

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:32:51 PDT 2025

Total time taken to generate the page: 0.00507 seconds