Failed to create new file

Hello folks,

I need your help to write files with the same label as the input files. I calculate the number of characters in the input folder and insert it in the write function, but it doesn’t seem to work. It throws an error after the first execution. Any efficient idea please.

DISK = glob("projects/Rhapsodie/Data/Disk/*","/")
for files in DISK
        name = files[31:end-5]
        write(FitsFile,"JonesParameters_Synthetic_Star_Gain_$gain-Real_$i-"*name*".fits", mapslices(transpose,J,dims=[1,2]), overwrite=true)

Error :

failed to create new file (already exists?)

Could you provide a MWE (minimal working example) for reproducing your use case?
There are several variables used in your current example, which are unclear, e.g. what is FitsFile? The complete write function call seems to be strange from here.


You can interpolate string variables when constructing strings the same way you interpolate gain, see

julia> name = "AAA"

julia> println("my name is $name")
my name is AAA

However if name is an Array of names, then you should probably iterate over that array.