Here is a quick typed on iPhone version, it "should" work. Will get all
scripts under root folder and sub-folder and add them under the same
menu. Adding sub-menu based on folders structure should not be too hard,
you just need to modify the code a bit
import os
import nuke
def build_templates(templates_location):
menu = nuke.menu("Nuke").addMenu("Nuke Templates")
for root, folder, files in os.walk(templates_location):
for f in files:
print root, f
name = os.path.splitext(f)[0]
menu.addCommand(name, 'nuke.nodePaste("%s/%s")' % (root , f))
build_templates("/Users/hugoleveille/.nuke/templates/")
On Fri, Apr 1, 2016, at 19:59, Hugo Léveillé wrote:
> You would have to use os.walk
>
> I'll make you an example this week-end if you need it
>
> Sent from my iPhone
>
> On Apr 1, 2016, at 7:57 PM, Darren Coombes
> <[email protected]> wrote:
>> Yep, worked a treat Hugo.
>> Thanks.
>>
>> Any idea how you’d get it to add subfolders in this also?
>>
>> * Check out some of my work...*
>>
>> **www.vimeo.com/darrencoombes/reel2015**
>>
>>
>>
>>
>>
>> **Mob: +61 418 631 079[1]**
>>
>>
>>
>>
>>
>>
>>
>>
>> *Instagram: @7secondstoblack*
>> *Instagram: @durwood0781*
>> *Skype: darren.coombes81*
>> *Twitter: @durwood81*
>>
>>
>>
>>
>>
>>
>>
>>> On 30 Mar 2016, at 10:16 am, Hugo Léveillé <[email protected]>
>>> wrote:
>>>
>>> Here is a quick example. Add this to your menu.py and change with
>>> your desired folder location containing your .nk files
>>>
>>> *import *os
>>>
>>>
>>>
>>> *import *nuke
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *def *build_templates(templates_location):
>>>
>>>
>>>
>>> menu = nuke.menu("Nuke").addMenu("Nuke Templates")
>>>
>>>
>>>
>>> *for *script *in *os.listdir(templates_location):
>>>
>>>
>>>
>>> name = os.path.splitext(script)[]
>>>
>>>
>>>
>>> menu.addCommand(name, 'nuke.nodePaste("%s/%s")' %
>>> (templates_location , script))
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> build_templates("/Users/hugoleveille/.nuke/templates/")
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Hugo Léveillé
>>> Head of 2D, MELS
>>> [email protected]
>>>
>>>
>>>
>>> On Tue, Mar 29, 2016, at 18:22, Darren Coombes wrote:
>>>> Yeah, I've got heaps of tool sets. Just trying something different,
>>>> so it could be step up on more of a per project basis kind of
>>>> thing.
>>>>
>>>>
>>>> *Check out some of my work...*
>>>>
>>>> **www.vimeo.com/darrencoombes/reel2015**
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> **Mob: +61 418 631 079[2]**
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *Instagram: @7secondstoblack*
>>>> *Instagram: @durwood0781*
>>>> *Skype: darren.coombes81*
>>>> *Twitter: @durwood81*
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On 30 Mar 2016, at 8:15 AM, Hugo Léveillé <[email protected]>
>>>> wrote:
>>>>> Why don't you use the toolsets? That's exactly what it does
>>>>>
>>>>> Sent from my iPhone
>>>>>
>>>>> On Mar 29, 2016, at 5:11 PM, Darren Coombes
>>>>> <[email protected]> wrote:
>>>>>> How would I make a menu item that links to a designated folder
>>>>>> full of nuke scripts i made as templates?
>>>>>> I have made the menu item as…
>>>>>>
>>>>>> nuke.menu("Nuke").addCommand("Nuke Templates/Testing”)
>>>>>>
>>>>>> which makes the menu item, but how would i tell it to list the
>>>>>> nuke scripts inside that folder?
>>>>>>
>>>>>> Thanks.
>>>>>> Darren.
>>>>>> * Check out some of my work...*
>>>>>>
>>>>>> **www.vimeo.com/darrencoombes/reel2015**
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> **Mob: +61 418 631 079[3]**
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> *Instagram: @7secondstoblack*
>>>>>> *Instagram: @durwood0781*
>>>>>> *Skype: darren.coombes81*
>>>>>> *Twitter: @durwood81*
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Nuke-users mailing list
>>>>>> [email protected],
>>>>>> http://forums.thefoundry.co.uk/
>>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>>> _______________________________________________
>>>>> Nuke-users mailing list
>>>>> [email protected],
>>>>> http://forums.thefoundry.co.uk/
>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>> _________________________________________________
>>>> Nuke-users mailing list
>>>> [email protected],
>>>> http://forums.thefoundry.co.uk/
>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>>>
>>> _______________________________________________
>>> Nuke-users mailing list
>>> [email protected], http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>> _______________________________________________
>> Nuke-users mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
> _________________________________________________
> Nuke-users mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
Links:
1. tel:+61%20418%20631%20079
2. tel:+61%20418%20631%20079
3. tel:+61%20418%20631%20079
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users