Page 1 of 1

Python Resolve Create Subfolder

PostPosted: Wed Oct 09, 2019 7:36 am
by Benjamin Kratzin
Hi everyone,

I'm currently trying to use Python in Resolve and got everything to work so far. Whats not working is creating subfolders in the Media Bin of folders created with python. I already know the function AddSubFolder()
but don't know how to use it, my current status is below. I don't know how to make a subfolder for example "00_Master") as I only get it to work when I call the mediapoolRoot.
But I'm sure there is someone knowing what I'm missing :)

project = projectManager.GetCurrentProject()
mediapool = project.GetMediaPool()
mediapoolRoot = mediapool.GetRootFolder()
resolve_media_storage = resolve.GetMediaStorage()
#parentFolder = mediapool.GotoParentFolder()
currentFolder = mediapool.GetCurrentFolder()

#Create Folders
mediapool.AddSubFolder(mediapoolRoot, "00_MASTER")
mediapool.AddSubFolder(OpenFolder("00_MASTER"), "Edits")


Thank you! Cheers

Re: Python Resolve Create Subfolder

PostPosted: Wed Oct 09, 2019 9:47 am
by iddos-l
Hi,
try this:

Code: Select all
rootFolder = mediapool.GetRootFolder()
currentFolder = mediapool.GetCurrentFolder()

#Create Folders
mediapool.AddSubFolder(rootFolder, "00_MASTER")
mediapool.AddSubFolder(currentFolder, "00_MASTER_2")

mediapool.SetCurrentFolder("00_MASTER")
master00 = mediapool.GetCurrentFolder()
mediapool.AddSubFolder(master00, "edit")


Re: Python Resolve Create Subfolder

PostPosted: Thu Oct 17, 2019 8:07 am
by Benjamin Kratzin
You're amazing, thank you for the fast answer. Sorry for the late reply but it worked like charm!!!

Re: Python Resolve Create Subfolder

PostPosted: Thu Oct 17, 2019 9:40 am
by Rick van den Berg
Hey, i think this python thing is really interesting. I have almost zero knowledge about coding in general, but i'm about to dive into it (for other purposes then editing mainly). just a question out of curiousity. maybe i'm thinking this all wrong. But.. does the python environment in resolve allow one to theoretically build something like a hardware panel that controls various editing/audio-related operations like adjusting the audio gain, setting audio keyframes, on specific audio-tracks, with all kinds of buttons like knobs, faders, keys, etc? i can imagine something in theory that would fit my needs perfectly.

Re: Python Resolve Create Subfolder

PostPosted: Thu Oct 17, 2019 12:02 pm
by iddos-l
Rick van den Berg wrote:Hey, i think this python thing is really interesting. I have almost zero knowledge about coding in general, but i'm about to dive into it (for other purposes then editing mainly). just a question out of curiousity. maybe i'm thinking this all wrong. But.. does the python environment in resolve allow one to theoretically build something like a hardware panel that controls various editing/audio-related operations like adjusting the audio gain, setting audio keyframes, on specific audio-tracks, with all kinds of buttons like knobs, faders, keys, etc? i can imagine something in theory that would fit my needs perfectly.


Some of what your asking is still not supported in the API.
Check the documentation.
Here is an easy to read doc:

https://forum.blackmagicdesign.com/memb ... le&u=52950

Re: Python Resolve Create Subfolder

PostPosted: Sat Jul 04, 2020 8:38 am
by Isazaly Mohamed Isa
I am getting this error code :(

Traceback (most recent call last):
File "<nofile>", line 1, in <module>
NameError: name 'mediapool' is not defined

Re: Python Resolve Create Subfolder

PostPosted: Sat Jul 04, 2020 8:41 am
by iddos-l
Isazaly Mohamed Isa wrote:I am getting this error code :(

Traceback (most recent call last):
File "<nofile>", line 1, in <module>
NameError: name 'mediapool' is not defined

Were you able to get the resolve object?
Can you share your code?


Sent from my iPhone using Tapatalk

Re: Python Resolve Create Subfolder

PostPosted: Fri Feb 19, 2021 1:21 am
by jensenni
How do I check if a folder name 'foe' already exists?

Re: Python Resolve Create Subfolder

PostPosted: Sat Feb 20, 2021 8:28 pm
by jensenni
Hey there, I made it work meantime :)



In terms of code let me know what you need and how I can help :)

best

Jens