## Display clip (file) name?

duofuan
Posts: 14
Joined: Sun May 27, 2018 3:18 am

### Display clip (file) name?

Hi.

I'm completely new to fusion. I would like to create a script of setting to get a file name, take a part of it and display it as lower 3drs.

Could you help me?

Cheers!

Midgardsormr
Fusionator
Posts: 1053
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 61 times
Contact:

### Re: Display clip (file) name?

This thread will get you started:

viewtopic.php?p=10922#p10922

Parsing the filename so you're not showing the entire path can be done with bmd.parseFilename(), which is described in the scriptlib.lua file in your Scripts folder. For your convenience, here is the documentation from that file:

Code: Select all

------------------------------------------------------------------------------
-- parseFilename()
--
-- this is a great function for ripping a filepath into little bits
-- returns a table with the following
--
-- FullPath	: The raw, original path sent to the function
-- Path		: The path, without filename
-- FullName	: The name of the clip w\ extension
-- Name     : The name without extension
-- CleanName: The name of the clip, without extension or sequence
-- SNum		: The original sequence string, or "" if no sequence
-- Number 	: The sequence as a numeric value, or nil if no sequence
-- Extension: The raw extension of the clip
-- Padding	: Amount of padding in the sequence, or nil if no sequence
-- UNC		: A true or false value indicating whether the path is a UNC path or not
------------------------------------------------------------------------------

In Andrew's example comp, the Text+ tool's Styled Text input has this expression:
Text(self:GetSourceTool("MetadataSource").Output.Metadata.Filename)
which will show the full path of the current file. You can use parseFilename() to take just the part you want like so:
Text(bmd.parseFilename(self:GetSourceTool("MetadataSource").Output.Metadata.Filename).CleanName)

To break that down a little, working from inside to outside, self:GetSourceTool() will return the tool connected to an input, in this case "MetadataSource", which is the name of the custom image input that was added to the Text+ tool. The tool that we get in this fashion is assumed to have a standard output called Output, and you can read metadata off it, one field of which will be the filename. So we have someTool.Output.Metadata.Filename, which returns the full path of the image. That is what you feed to parseFilename().CleanName, which returns the CleanName field from the table described above. And, finally, Text() returns a Text object that the Text+ tool can use.

If you were doing this in a script, you'd probably assign variables for each piece, making it easier to read, but that's more difficult to do in a Simple Expression (not impossible, but probably more trouble than it's worth in this case).

duofuan
Posts: 14
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

duofuan
Posts: 14
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

After trying many times different variations finally I've found the variation witch works for me:
in text+ node the expression is : self:GetSourceTool("MetadataSource").ClipName

The ones in your example didn't work at all.

Now the question is - how to apply this comp to all clips in my timeline at once?

Iddos
Posts: 12
Joined: Sat Oct 06, 2018 4:21 pm
Been thanked: 2 times

### Re: Display clip (file) name?

Now the question is - how to apply this comp to all clips in my timeline at once?
You can try using resolve script API to import fusion comp onto every clip in timeline.

duofuan
Posts: 14
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

Thanks Iddos, I'll try to figure it out.

SirEdric
Fusionator
Posts: 1820
Joined: Tue Aug 05, 2014 10:04 am
Real name: Eric Westphal
Been thanked: 97 times
Contact:

### Re: Display clip (file) name?

duofuan wrote:
Sun Jul 14, 2019 4:31 pm
in text+ node the expression is : self:GetSourceTool("MetadataSource").ClipName
Hmmm...interesting.
But how do you define the SourceTool of a Text+?

Midgardsormr
Fusionator
Posts: 1053
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 61 times
Contact:

### Re: Display clip (file) name?

SirEdric wrote:
Sun Jul 21, 2019 2:15 am
duofuan wrote:
Sun Jul 14, 2019 4:31 pm
in text+ node the expression is : self:GetSourceTool("MetadataSource").ClipName
Hmmm...interesting.
But how do you define the SourceTool of a Text+?
MetadataSource is a user control on the Text+. That was set up in Andrew's thread that I linked to early on.

duofuan: Apologies that I didn't test what I suggested. I was on vacation and didn't have Fusion or Resolve available to me, so I was working entirely from memory. If I had noticed that this was posted in the Resolve forum, I'd have been more careful, since a MediaIn doesn't work the same way as a Loader, and you don't actually need to parse out the path. And now that I stop to think about it, I don't think a Simple Expression can access the scriptlib, anyway, so I failed on two counts. :/

I don't have a clue about working with Resolve's timeline, so I can't help you there, but I'm glad you at least got the first part of the puzzle solved!

SirEdric
Fusionator
Posts: 1820
Joined: Tue Aug 05, 2014 10:04 am
Real name: Eric Westphal
Been thanked: 97 times
Contact:

### Re: Display clip (file) name?

Midgardsormr wrote:
Sun Jul 21, 2019 7:59 am
MetadataSource is a user control on the Text+. That was set up in Andrew's thread that I linked to early on.
Ah! I see! Totally missed that one...

Iddos
Posts: 12
Joined: Sat Oct 06, 2018 4:21 pm
Been thanked: 2 times

### Re: Display clip (file) name?

For adding fu comps to timeline clips using python:

After instantiating a Resolve object. (I'm using "python_get_resolve")

This should do it:
1. from python_get_resolve import GetResolve
2.
3. resolve = GetResolve()
4.
5. projectManager = resolve.GetProjectManager()
6. project = projectManager.GetCurrentProject()
7. currentTimeline = project.GetCurrentTimeline()
8.
9. video1Clips = currentTimeline.GetItemsInTrack('video', 1)
10.
11. for key in video1Clips:
12.     video1Clips[key].ImportFusionComp('PATH TO COMP.comp')

duofuan
Posts: 14
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

Thanks guys a lot for responses especially Iddos.
No problem Midgardsormr . After trials and errors slowly I'm getting there.

For a while I was out but now I have some time to try out the script.

One more (I figure simple) question is how to extract a part of a file name?
The result of expression self:GetSourceTool("MetadataSource").ClipName is a filename, in my case filenames are in format: 2018_05_31= 21_30_10.MP4

I was searching this on internet but without success. How can I adapt my expression above to get only date from filename like such: "2018-05-31" ?

What language is used for fusion expressions anyway? Is it lua?

duofuan
Posts: 14
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

So I'm making my steps forward.
I've found in Text+ properties on the tab with a cogwheel a lua script can be written into "Frame Render Script" field.
So after removing the expression from styled text field on "T" tab and pasting following lines int "Frame Render Script" :

self.StyledText = varr

it works as is should.

Using string.gsub() function on any string works fine but strangely if I use it on varr variable it won't execute the script.
Is is because varr is not a string? Is there a way to convert it?
I'm confused

SirEdric
Fusionator
Posts: 1820
Joined: Tue Aug 05, 2014 10:04 am
Real name: Eric Westphal
Been thanked: 97 times
Contact:

### Re: Display clip (file) name?

It should work when supplying an index: varr = self:GetSourceTool("MetadataSource").Clip[1].Filename

duofuan
Posts: 14
Joined: Sun May 27, 2018 3:18 am

### Re: Display clip (file) name?

I found that the result of self:GetSourceTool("MetadataSource").ClipName is of type cdata.
Now I need to figure how to cast cdata object to string and I'm home

SirEdric
Fusionator
Posts: 1820
Joined: Tue Aug 05, 2014 10:04 am