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

Home » Public Forums » archive » Re: Loop Multiple Files and Rename
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: Loop Multiple Files and Rename [message #67751] Sat, 22 August 2009 09:16 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
For your loop, start with FILE_SEARCH .This will find all your files and
return an array with every file name. Loop through this array, and use
David solution from there to change the file name

Jean


anniebryant@gmail.com wrote:
> Hi All,
>
> I have a pretty basic question.
>
> I have a list of MODIS images in a folder, all beginning with the
> prefix "MOD09GA" followed by a string of other characters, i.e.
> '.A2009138.h09v05.005.2009140163311_Grid_2D_reprojected.img'
>
> I have written a very basic little program to reorder the bands in the
> MODIS image, but I've only gotten it to work one image at a time.
>
> Ideally, I'd have a loop that takes each image from the folder,
> reorders the bands, then writes each file with a unique name.
>
> _________________________________
>
> pro MOD09GA_bandreorder
>
> ns=4578
> nl=2367
> nb=7
>
> image = fltarr(ns,nl,nb)
> morder=fltarr(ns,nl,nb)
> ;outfile=fltarr(ns,nl,nb)
>
> for i=1,11 do begin ; is this opening multiple files, or the same
> over and over?? figure it out AB!
>
> openr, i, '/users/u0609216/documents/modis/2009/Geo_2009/MOD09GA.*'
> readu, i, image
> close, i
>
> b1 = image(*,*,0)
> b2 = image(*,*,1)
> b3 = image(*,*,2)
> b4 = image(*,*,3)
> b5 = image(*,*,4)
> b6 = image(*,*,5)
> b7 = image(*,*,6)
> ; band order should be (3,4,1,2,5,6,7)
> morder[*,*,0]=b3
> morder[*,*,1]=b4
> morder[*,*,2]=b1
> morder[*,*,3]=b2
> morder[*,*,4]=b5
> morder[*,*,5]=b6
> morder[*,*,6]=b7
>
> print, "Now processing:" ,'file', i
>
> get_lun,unit
>
> openw,unit,'/users/u0609216/documents/modis/2009/reorder_200 9/
> reorder.bip'
> writeu,unit,morder
> close,unit
>
> endfor
>
> print, 'Done!'
>
> end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Loop Multiple Files and Rename
Next Topic: Re: CHISQR_CVF question.

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

Current Time: Wed Oct 08 19:14:06 PDT 2025

Total time taken to generate the page: 0.00592 seconds