Re: Writing each filename into new line of text file [message #91073 is a reply to message #91072] |
Mon, 01 June 2015 05:06   |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den måndag 1 juni 2015 kl. 11:20:38 UTC+2 skrev Kai Heckel:
> Am Montag, 1. Juni 2015 09:30:26 UTC+2 schrieb Kai Heckel:
>> Am Montag, 1. Juni 2015 09:24:23 UTC+2 schrieb Kai Heckel:
>>> Am Freitag, 29. Mai 2015 22:43:57 UTC+2 schrieb Dick Jackson:
>>>> On Friday, 29 May 2015 05:48:43 UTC-7, Kai Heckel wrote:
>>>> > Hey!
>>>> >
>>>> > I'd like to list my files and write them into a text file. Each filename should be in a separate line....
>>>> > Shouldn't be to hard ;)
>>>> >
>>>> > This is what I have:
>>>> >
>>>> > PRO test
>>>> > cd, 'Path of my files'
>>>> > files_all = FILE_SEARCH()
>>>> > openw,lun1,'fileinfo.txt', /get_lun
>>>> > printf, lun1, files_all, FORMAT='(A)'
>>>> > close, lun1
>>>> > free_lun,lun1
>>>> > END
>>>> >
>>>> > I couldn't find any suitable command till now...
>>>> >
>>>> > Thanks!
>>>>
>>>> As we often ask around here, "in what way is this not working for you?". When I run this, it does write every filename on a separate line, as expected. It also seems to be listing contained folders... is that the problem? If so, use this instead:
>>>>
>>>> files_all = FILE_SEARCH(/TEST_REGULAR)
>>>>
>>>> Bonus: if you're going to do "free_lun", you don't have to do "close"!
>>>>
>>>> Cheers,
>>>> -Dick
>>>>
>>>> Dick Jackson Software Consulting Inc.
>>>> Victoria, BC, Canada --- http://www.d-jackson.com
>>>
>>>
>>> Thank you very much for your solutions!
>>>
>>> @ Nikola:
>>> If I try your version it prints my datasets into 3 columns for some reason...
>>>
>>> @ Dick:
>>> "/TEST_REGULAR" returns an empty string (not an array as needed)
>>>
>>> I assume that it should be possible to reduce the number of columns in Nikolas version in some way.....isn't it?
>>>
>>> Thanks everyone!
>>
>> Hey! Me again ;)
>>
>> I found the solution it is, as always, surprisingly easy!
>> Replacing the format-argument "A" with "A0" worked out as desired.
>> Now every file is written to a new line!
>>
>> Thanks for your help!
>
> Hey!
>
> Another question just came up. In order to control my processing process with a lot of files I'd like to create two lists (txt.'s). One list contains the properly processed (ok_list) and one list the corrupt files(error_list). Based on an exitcode from my processor I'd like to write the name of the currently processed file into the correct list.
>
> The only problem I have here is that e.g. if 2 files are correctly processed the first line of my ok_list should not be overwritten. How do I manage to do that?
Read the manual for the OPENW command and find the APPEND keyword?
|
|
|