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

Home » Public Forums » archive » Re: file_search: need work around for filenames with square brackets [ ]
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: file_search: need work around for filenames with square brackets [ ] [message #66959 is a reply to message #66958] Mon, 15 June 2009 15:25 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
rklein wrote:
> On Jun 6, 7:03 am, David Fanning <n...@dfanning.com> wrote:
>> rklein writes:
>>> the routines for reading FITS-files in the IDL astro library use
>>> file_search() internally. Now I want to read a file name with square
>>> brackets (as this "[" and " this" ]" ) in it, but file_search seems to
>>> interpret the square brackets as regular expression. Is there a way to
>>> escape the brackets?
>>> Other suggestions?
>>> I don't really want to change the library routines not rename the
>>> files I have to read.
>>
>> Yeah, I hear you. I want to play tennis and hike in
>> the mountains instead of going to work every day. :-(
>>
>> Have you tried a back slash as an escape character?
>
> I'd rather go sailing, but could you come back from the tennis court
> please and have a look at this idl journal:
>
> ; IDL Version 7.0, Microsoft Windows (Win32 x86 m32)
> ; Journal File for Administrator@FIFILSTEST
> ; Working directory: C:\FIFILS\Software\FlightSoftware
> ; Date: Mon Jun 15 21:58:08 2009
>
> print,file_search("K:\OBSERVATIONS\archiveData
> \20090403_095540\00098_153217_spiral162_@0078*")
> ;K:\OBSERVATIONS\archiveData
> \20090403_095540\00098_153217_spiral162_@0078_[4,-4]_lw.dff
> ;K:\OBSERVATIONS\archiveData
> \20090403_095540\00098_153217_spiral162_@0078_[4,-4]_lw.fit
> ;K:\OBSERVATIONS\archiveData
> \20090403_095540\00098_153217_spiral162_@0078_[4,-4]_lw.rff
> print,file_search("K:\OBSERVATIONS\archiveData
> \20090403_095540\00098_153217_spiral162_@0078_\[4,-4\]_lw.df f ")
> print,file_search("K:\OBSERVATIONS\archiveData
> \20090403_095540\00098_153217_spiral162_@0078_/[4,-4/]_lw.df f ")
> print,file_search('"K:\OBSERVATIONS\archiveData
> \20090403_095540\00098_153217_spiral162_@0078_[4,-4]_lw.dff"')
>
> Of course, I tried escaping the brackets, but it does not work as you
> can see from the above. May be I should have mentioned that I am
> running on Windows

In fact, the expansion is performed by the shell (so it's not a
regular
expression kind of thing). So, you should use the character that the
windows shell uses for escaping. I am not sure myself what this
character
is, but you may want to try the ^ character.

Ciao,
Paolo
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDLDOC 3.2 Index page not as interesting as it could be...
Next Topic: update variable in structure

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

Current Time: Sat Oct 11 16:19:13 PDT 2025

Total time taken to generate the page: 2.48279 seconds