# Create a file for each plugin instance

**URL:** <https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169>\
**Category:** Audio Plugins\
**Created:** [July 3, 2017, 9:27am UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169 "2017-07-03T09:27:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jouetpas1u](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jouetpas1u](https://forum.juce.com/u/jouetpas1u)\
**Post date:** [July 3, 2017, 9:27am UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169/1 "2017-07-03T09:27:53Z")

</div>

Hello,  
i’m a newbie with Juce and C++.  
I want to create a text file for each plugin instance that I set. Each file should have a different name.  
I can do that by creating a static variable which is incremented when audioprocessor constructor is called, but if I launch two plugin host, I will have the same name for my first plugin instance of each host.  
is there a way to have an access to the PID from the pluginhost or the plugin instance itself (then I’m sure I have an unique name)? or do you have any other idea?  
Thanks a lot,  
Léo

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [July 3, 2017, 9:31am UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169/2 "2017-07-03T09:31:53Z")

</div>

The safest thing might be a [Uuid](https://juce.com/doc/classUuid).  
HTH

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [July 3, 2017, 9:31am UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169/3 "2017-07-03T09:31:58Z")

</div>

Check out this thread: [DefaultAppLogger and multiple instances of plugin](https://forum.juce.com/t/defaultapplogger-and-multiple-instances-of-plugin/13921) for some ideas.

Rail

---

<div class="post-metadata">

**Author:** ![jouetpas1u](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jouetpas1u](https://forum.juce.com/u/jouetpas1u)\
**Post date:** [July 3, 2017, 9:50am UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169/4 "2017-07-03T09:50:38Z")

</div>

> [@daniel](#):
>
> The safest thing might be a Uuid.  
> HTH

Thanks, but sorry, I forgot to precise that I need to have access to this ID outside my code and my plugin.  
thank again for the quick answer

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [July 3, 2017, 10:52am UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169/5 "2017-07-03T10:52:00Z")

</div>

I see. I would still create an Uuid in the plugin instance, but store it into a [SharedResourcePointer](https://juce.com/doc/classSharedResourcePointer), that @Rail_Jon_Rogut suggested in his thread?

Anyway, you will put the pieces together 😉

---

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [July 3, 2017, 3:38pm UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169/6 "2017-07-03T15:38:53Z")

</div>

Depends on the degree of “uniqueness” that you need to obtain.

Using PID is still not granting you to obtain a unique ID after you restart your computer. If that’s the degree of uniqueness that you need, you can also make use of [`PluginHostType`](https://www.juce.com/doc/classPluginHostType), which will give you the name of the DAW that is running your plug-ins.

Combine that with the instance number obtained from your `static` counter, and you should have a fairly decent and readable “identifier” for your instances that run concurrently.

---

<div class="post-metadata">

**Author:** ![pauloesteban](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@pauloesteban](https://forum.juce.com/u/pauloesteban)\
**Post date:** [April 3, 2019, 12:32am UTC](https://forum.juce.com/t/create-a-file-for-each-plugin-instance/23169/7 "2019-04-03T00:32:01Z")

</div>

I am working on a similar feature. I am using `Uuid().ToString` in the plugin constructor. I load the plugin on a track in Live and Reaper, but each time I close the plugin window (not unloading/removing the plugin) the uuid changes.

How can I retain the uuid for each instance until I unload the plugin?
