# Failed to create new file

**URL:** <https://discourse.julialang.org/t/failed-to-create-new-file/64756>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 16, 2021, 2:58pm UTC](https://discourse.julialang.org/t/failed-to-create-new-file/64756 "2021-07-16T14:58:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![assia855](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/assia855/32/22845_2.png) [@assia855](https://discourse.julialang.org/u/assia855)\
**Post date:** [July 16, 2021, 2:58pm UTC](https://discourse.julialang.org/t/failed-to-create-new-file/64756/1 "2021-07-16T14:58:49Z")

</div>

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.

```julia

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?)

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [July 18, 2021, 1:49pm UTC](https://discourse.julialang.org/t/failed-to-create-new-file/64756/2 "2021-07-18T13:49:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pakk-minidose](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pakk-minidose/32/27126_2.png) [@pakk-minidose](https://discourse.julialang.org/u/pakk-minidose)\
**Post date:** [July 19, 2021, 11:03am UTC](https://discourse.julialang.org/t/failed-to-create-new-file/64756/3 "2021-07-19T11:03:08Z")

</div>

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

```julia
julia> name = "AAA"
"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.
