Create folder below certain file [message #90849] |
Tue, 28 April 2015 04:58  |
Kai Heckel
Messages: 51 Registered: April 2015
|
Member |
|
|
Hello everyone!
I am currently working on an IDL project in which I want to find a specified file. Once I set the definition for my "IF"-statement, I want to create a new folder below the file...
So this is basically what it looks like:
IF (substring_month EQ '01') then begin
FILE_MKDIR, '/January'
FILE_MOVE, dirname[k], 'January'
ENDIF
This block is part of a "FOR"-loop, which defines "dirname" as the name of a folder.
I'd really appreciate your help!
Thanks everyone
|
|
|
Re: Create folder below certain file [message #90850 is a reply to message #90849] |
Tue, 28 April 2015 08:02   |
Phillip Bitzer
Messages: 223 Registered: June 2006
|
Senior Member |
|
|
On Tuesday, April 28, 2015 at 6:58:27 AM UTC-5, Kai Heckel wrote:
> Hello everyone!
>
> I am currently working on an IDL project in which I want to find a specified file. Once I set the definition for my "IF"-statement, I want to create a new folder below the file...
>
> So this is basically what it looks like:
>
> IF (substring_month EQ '01') then begin
> FILE_MKDIR, '/January'
> FILE_MOVE, dirname[k], 'January'
> ENDIF
Well, '/January' specifies the root directory. To create a new directory in the current working directory, use './January' instead.
Of course, this assumes the current working directory is where you find the specified file. A more robust piece of code would parse the result from whatever function you use to find the file.
|
|
|
|
|
Re: Create folder below certain file [message #90863 is a reply to message #90860] |
Wed, 29 April 2015 11:51  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 4/29/15 2:26 AM, Kai Heckel wrote:
> Am Dienstag, 28. April 2015 13:58:27 UTC+2 schrieb Kai Heckel:
>> Hello everyone!
>>
>> I am currently working on an IDL project in which I want to find a
>> specified file. Once I set the definition for my "IF"-statement, I
>> want to create a new folder below the file...
>>
>> So this is basically what it looks like:
>>
>> IF (substring_month EQ '01') then begin FILE_MKDIR, '/January'
>> FILE_MOVE, dirname[k], 'January' ENDIF
>>
>>
>> This block is part of a "FOR"-loop, which defines "dirname" as the
>> name of a folder.
>>
>> I'd really appreciate your help!
>>
>>
>> Thanks everyone
>
>
> I found a solution for my problem.
>
> By simply cutting the path using STRMID and saving it into a variable
> it is possible to refer to this path later.
>
FILE_BASENAME, FILE_DIRNAME, and FILEPATH might be handy here, instead
of having to use STRPOS and STRMID.
-Mike
|
|
|