Iteration in for loop

Hello Folks,

I got a folder full of files. I would like to iterate 5 times each file in the folder. I got this bellow code, but I don’t have idea how to iterate 5 times each file in the folder.

DISK = glob("disk/*")

for files in DISK

		DISKS = read(FitsArray, files);
		Iu=gain .* DISKS[:,:,1];
		
        write(FitsArray, Iu)
end

What’s wrong with just

for files in DISK
    for i in 1:5
         [do whatever you have to do five times]
    end
end

?

1 Like

Thank you, and i where should I insert it to iterate 5 times

Where the square brackets are - a more complete example

julia> files = ["File $i" for i ∈ 1:3]
3-element Vector{String}:
 "File 1"
 "File 2"
 "File 3"

julia> for f ∈ files
           for i ∈ 1:5
               println("Working on file $f, iteration number $i")
           end
       end
Working on file File 1, iteration number 1
Working on file File 1, iteration number 2
Working on file File 1, iteration number 3
Working on file File 1, iteration number 4
Working on file File 1, iteration number 5
Working on file File 2, iteration number 1
Working on file File 2, iteration number 2
Working on file File 2, iteration number 3
Working on file File 2, iteration number 4
Working on file File 2, iteration number 5
Working on file File 3, iteration number 1
Working on file File 3, iteration number 2
Working on file File 3, iteration number 3
Working on file File 3, iteration number 4
Working on file File 3, iteration number 5
3 Likes